From 9235e0e2ac7a1a9a02c9293d85730f3466c1f96a Mon Sep 17 00:00:00 2001 From: Yimeng Wu Date: Fri, 24 Nov 2023 22:50:12 +0000 Subject: [PATCH] Port microsoft/microsoft-ui-xaml#4573 (#627) --- .../NavigationView/NavigationView.cs | 13 +---------- .../NavigationView/NavigationView.xaml | 20 +++++++++++++--- ModernWpf/Styles/NavigationBackButton.xaml | 2 +- ModernWpf/Styles/NavigationView.xaml | 23 +++++++++++-------- ModernWpf/ThemeResources/Dark.xaml | 10 ++++---- ModernWpf/ThemeResources/HighContrast.xaml | 4 ++-- ModernWpf/ThemeResources/Light.xaml | 10 ++++---- .../Common/NavigationViewPage.xaml | 2 +- 8 files changed, 45 insertions(+), 39 deletions(-) diff --git a/ModernWpf.Controls/NavigationView/NavigationView.cs b/ModernWpf.Controls/NavigationView/NavigationView.cs index 50a6df84..eb31b595 100644 --- a/ModernWpf.Controls/NavigationView/NavigationView.cs +++ b/ModernWpf.Controls/NavigationView/NavigationView.cs @@ -1849,18 +1849,7 @@ void UpdatePaneButtonsWidths() { var templateSettings = GetTemplateSettings(); - double newButtonWidths; - { - double init() - { - if (DisplayMode == NavigationViewDisplayMode.Minimal) - { - return c_paneToggleButtonWidth; - } - return CompactPaneLength; - } - newButtonWidths = init(); - } + var newButtonWidths = CompactPaneLength; templateSettings.PaneToggleButtonWidth = newButtonWidths; templateSettings.SmallerPaneToggleButtonWidth = newButtonWidths - 8; diff --git a/ModernWpf.Controls/NavigationView/NavigationView.xaml b/ModernWpf.Controls/NavigationView/NavigationView.xaml index 0cb1d832..dbe6eaf6 100644 --- a/ModernWpf.Controls/NavigationView/NavigationView.xaml +++ b/ModernWpf.Controls/NavigationView/NavigationView.xaml @@ -550,7 +550,7 @@ x:Name="IconBox" Height="16" Width="16" - Margin="12,0,0,0" + Margin="16,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"> + MinWidth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.SmallerPaneToggleButtonWidth}" + ui:FocusVisualHelper.FocusVisualMargin="0"> + @@ -1255,7 +1257,19 @@ x:Name="PaneAutoSuggestButton" Visibility="Collapsed" Style="{DynamicResource NavigationViewPaneSearchButtonStyle}" - Width="{TemplateBinding CompactPaneLength}"/> + Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.SmallerPaneToggleButtonWidth}"> + + + + + + + + + + + + - + diff --git a/ModernWpf/Styles/NavigationView.xaml b/ModernWpf/Styles/NavigationView.xaml index e31efaa4..6efb0d5d 100644 --- a/ModernWpf/Styles/NavigationView.xaml +++ b/ModernWpf/Styles/NavigationView.xaml @@ -13,10 +13,10 @@ 10,0,16,0 12,0,12,0 34 - 46 + 38 46 38 - 48 + 40 40 40 40 @@ -27,7 +27,7 @@ 1 1 - 1 + 0 1 11,0,11,0 12,0 @@ -68,7 +68,6 @@ - @@ -76,7 +75,8 @@ - + + @@ -141,7 +141,10 @@