lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.67k stars 747 forks source link

NavigationView SelectionChanged event not firing #1183

Open Muxammadamin-Ulmasaliyev opened 3 months ago

Muxammadamin-Ulmasaliyev commented 3 months ago

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 ! "); }

textGamex commented 2 months ago

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

BoyFaceGirl commented 2 months ago

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?