From 9438944a0f4158c43b2d2fcd5c24d0914a9cc117 Mon Sep 17 00:00:00 2001 From: Vignesh-SF3580 Date: Fri, 17 Jan 2025 11:51:23 +0530 Subject: [PATCH 1/2] [Windows]Fixed Shell Navigating event issue when switching tabs --- .../Shell/ShellItemHandler.Windows.cs | 16 ++++++++- .../TestCases.HostApp/Issues/Issue25599.xaml | 36 +++++++++++++++++++ .../Issues/Issue25599.xaml.cs | 35 ++++++++++++++++++ .../Tests/Issues/Issue25599.cs | 27 ++++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25599.cs diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index 8d27b8904862..31af2550227a 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -141,8 +141,22 @@ private void OnNavigationTabChanged(NavigationView sender, NavigationViewSelecti var selectedItem = (NavigationViewItemViewModel)args.SelectedItem; - if (selectedItem.Data is ShellSection shellSection) + if (selectedItem.Data is ShellSection shellSection && VirtualView.Parent is Shell shell) { + NavigationViewItemViewModel? currentItem = null; + foreach (var item in _mainLevelTabs) + { + if (shell.CurrentItem?.CurrentItem is not null && item.Data == shell.CurrentItem.CurrentItem) + { + currentItem = item; + break; + } + } + if (PlatformView is NavigationView navView && navView?.SelectedItem is not null && navView.SelectedItem != currentItem) + { + ((IShellItemController)shell.CurrentItem!).ProposeSection(shellSection); + } + ((Shell)VirtualView.Parent).CurrentItem = shellSection; } else if (selectedItem.Data is ShellContent shellContent) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml new file mode 100644 index 000000000000..97250e40d3ed --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml @@ -0,0 +1,36 @@ + + + + + + + + + +