Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NavigationView SelectionChanged event not firing #1183

Open
Muxammadamin-Ulmasaliyev opened this issue Jul 30, 2024 · 3 comments
Open

NavigationView SelectionChanged event not firing #1183

Muxammadamin-Ulmasaliyev opened this issue Jul 30, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Muxammadamin-Ulmasaliyev

Describe the bug

The SelectionChanged event in the NavigationView control does not fire when a new item is selected.

To Reproduce

  1. Create a NavigationView control in a WPF application.
  2. Add several NavigationViewItems to the control.
  3. Implement the SelectionChanged event handler in the code-behind.
  4. Run the application and attempt to select different items in the NavigationView.

Expected behavior

The SelectionChanged event should fire each time a different item is selected, allowing appropriate handling of the selection change.

Screenshots

No response

OS version

Windows 11 pro 23H2

.NET version

.NET 8

WPF-UI NuGet version

WPF-UI 3.0.5

Additional context

 <ui:NavigationView
     x:Name="sidebarNavigationView"
     IsPaneToggleVisible="True"
     OpenPaneLength="130"
     SelectionChanged="sidebarNavigationView_SelectionChanged">
     <ui:NavigationView.MenuItems>
         <ui:NavigationViewItem Content="Collections">
             <ui:NavigationViewItem.Icon>
                 <ui:SymbolIcon Style="{StaticResource LargeSymbolIconStyle}" Symbol="Folder48" />
             </ui:NavigationViewItem.Icon>
         </ui:NavigationViewItem>
         <ui:NavigationViewItem Content="Environments">
             <ui:NavigationViewItem.Icon>
                 <ui:SymbolIcon Style="{StaticResource LargeSymbolIconStyle}" Symbol="AppsListDetail24" />
             </ui:NavigationViewItem.Icon>
         </ui:NavigationViewItem>
         <ui:NavigationViewItem Content="History">
             <ui:NavigationViewItem.Icon>
                 <ui:SymbolIcon Style="{StaticResource LargeSymbolIconStyle}" Symbol="History48" />
             </ui:NavigationViewItem.Icon>
         </ui:NavigationViewItem>
     </ui:NavigationView.MenuItems>
     <ui:NavigationView.FooterMenuItems>
         <ui:NavigationViewItem Content="Settings">
             <ui:NavigationViewItem.Icon>
                 <ui:SymbolIcon Symbol="Settings24" />
             </ui:NavigationViewItem.Icon>
         </ui:NavigationViewItem>
     </ui:NavigationView.FooterMenuItems>
 </ui:NavigationView>

private void sidebarNavigationView_SelectionChanged(NavigationView sender, RoutedEventArgs args)
{
System.Windows.MessageBox.Show("Selection changed ! ");
}

@Muxammadamin-Ulmasaliyev Muxammadamin-Ulmasaliyev added the bug Something isn't working label Jul 30, 2024
@textGamex
Copy link
Contributor

You need to set the TargetPageType property of NavigationViewItem to properly trigger the SelectionChanged event

@BoyFaceGirl
Copy link

You need to set the TargetPageType property of NavigationViewItem to properly trigger the SelectionChanged event

Anyway, this is unreasonable. Why does TargetPageType=null affect the SelectionChanged event of NavigationViewItem?

@Justin1107-good
Copy link

Do you have a three-level NavigationViewItem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants