From 6b6b0faadfcdda46d213e107f9eb17fe50b65843 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 21 Nov 2024 22:07:35 +0800 Subject: [PATCH 1/2] fix possible content frame navigation issue --- Flow.Launcher/SettingWindow.xaml | 1 + Flow.Launcher/SettingWindow.xaml.cs | 24 ++++++++++++++++++++++-- Flow.Launcher/WelcomeWindow.xaml | 15 ++++++++------- Flow.Launcher/WelcomeWindow.xaml.cs | 9 +++++++-- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index f6381b46586..a81d9e0d108 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -171,6 +171,7 @@ IsPaneToggleButtonVisible="False" IsSettingsVisible="False" IsTabStop="False" + Loaded="NavView_Loaded" OpenPaneLength="240" PaneDisplayMode="Left" SelectionChanged="NavigationView_SelectionChanged"> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 4cc125fa4af..cb3f1e4a113 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -29,7 +29,6 @@ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel) _api = api; InitializePosition(); InitializeComponent(); - NavView.SelectedItem = NavView.MenuItems[0]; /* Set First Page */ } private void OnLoaded(object sender, RoutedEventArgs e) @@ -169,7 +168,11 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi else { var selectedItem = (NavigationViewItem)args.SelectedItem; - if (selectedItem == null) return; + if (selectedItem == null) + { + NavView_Loaded(sender, null); /* Reset First Page */ + return; + } var pageType = selectedItem.Name switch { @@ -186,5 +189,22 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi } } + private void NavView_Loaded(object sender, RoutedEventArgs e) + { + if (ContentFrame.IsLoaded) + { + ContentFrame_Loaded(sender, e); + } + else + { + ContentFrame.Loaded += ContentFrame_Loaded; + } + } + + private void ContentFrame_Loaded(object sender, RoutedEventArgs e) + { + NavView.SelectedItem ??= NavView.MenuItems[0]; /* Set First Page */ + } + public record PaneData(Settings Settings, Updater Updater, IPortable Portable); } diff --git a/Flow.Launcher/WelcomeWindow.xaml b/Flow.Launcher/WelcomeWindow.xaml index 003dac5bcd8..d8cb38149a8 100644 --- a/Flow.Launcher/WelcomeWindow.xaml +++ b/Flow.Launcher/WelcomeWindow.xaml @@ -43,12 +43,12 @@ Grid.Column="0" Width="16" Height="16" - Margin="10,4,4,4" + Margin="10 4 4 4" RenderOptions.BitmapScalingMode="HighQuality" Source="/Images/app.png" /> @@ -97,7 +98,7 @@ Grid.Row="1" Background="{DynamicResource Color00B}" BorderBrush="{DynamicResource PopupButtonAreaBorderColor}" - BorderThickness="0,1,0,0"> + BorderThickness="0 1 0 0"> @@ -111,7 +112,7 @@ VerticalAlignment="Center">