From d23f22507aaf7e1caa1d648a5c9f89ec661cc792 Mon Sep 17 00:00:00 2001 From: Yimeng Wu Date: Wed, 6 Dec 2023 22:51:46 +0000 Subject: [PATCH] Port microsoft/microsoft-ui-xaml#4659 --- .../NavigationView/NavigationView.cs | 15 ++ .../NavigationView/NavigationView.xaml | 246 ++++++++++-------- ModernWpf.Controls/SplitView/SplitView.cs | 3 +- ModernWpf.Controls/SplitView/SplitView.xaml | 41 +-- ModernWpf/Controls/ControlEx.cs | 22 ++ ModernWpf/ControlsResources.xaml | 6 + .../Common/NavigationViewPage.xaml | 6 +- 7 files changed, 208 insertions(+), 131 deletions(-) create mode 100644 ModernWpf/Controls/ControlEx.cs diff --git a/ModernWpf.Controls/NavigationView/NavigationView.cs b/ModernWpf.Controls/NavigationView/NavigationView.cs index eb31b595..9048146e 100644 --- a/ModernWpf.Controls/NavigationView/NavigationView.cs +++ b/ModernWpf.Controls/NavigationView/NavigationView.cs @@ -1790,6 +1790,8 @@ void OnSplitViewPaneClosing(DependencyObject sender, SplitViewPaneClosingEventAr VisualStateManager.GoToState(this, "ListSizeCompact", true /*useTransitions*/); UpdatePaneToggleSize(); } + + VisualStateManager.GoToState(this, "PaneNotOverlaying", true /*useTransitions*/); } } } @@ -1806,6 +1808,14 @@ void OnSplitViewPaneOpening(DependencyObject sender, object obj) { // See UpdateIsClosedCompact 'RS3+ animation timing enhancement' for explanation: VisualStateManager.GoToState(this, "ListSizeFull", true /*useTransitions*/); + + if (m_rootSplitView is { } splitView) + { + if (splitView.DisplayMode == SplitViewDisplayMode.CompactOverlay || splitView.DisplayMode == SplitViewDisplayMode.Overlay) + { + VisualStateManager.GoToState(this, "PaneOverlaying", true /*useTransitions*/); + } + } } PaneOpening?.Invoke(this, null); @@ -4636,6 +4646,11 @@ void UpdateBackAndCloseButtonsVisibility() if (m_paneContentGrid is { } paneContentGridAsUIE) { + if (paneContentGridAsUIE is Border paneContentGridAsBorder) + { + paneContentGridAsUIE = paneContentGridAsBorder.Child; + } + if (paneContentGridAsUIE is Grid paneContentGrid) { var rowDefs = paneContentGrid.RowDefinitions; diff --git a/ModernWpf.Controls/NavigationView/NavigationView.xaml b/ModernWpf.Controls/NavigationView/NavigationView.xaml index 3ffe531d..328838c2 100644 --- a/ModernWpf.Controls/NavigationView/NavigationView.xaml +++ b/ModernWpf.Controls/NavigationView/NavigationView.xaml @@ -920,6 +920,14 @@ + + + + + + + + @@ -1026,7 +1034,7 @@ VerticalAlignment="Center" Style="{DynamicResource NavigationViewItemHeaderTextStyle}"/> - + @@ -1190,142 +1198,147 @@ + Grid.Row="1" + CornerRadius="{DynamicResource OverlayCornerRadius}"> - - - - - - - - - - - - - - - - + + - + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + Grid.Row="4" /> - - - - - + + + - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - + + @@ -1389,6 +1402,13 @@ + + + + + + + diff --git a/ModernWpf.Controls/SplitView/SplitView.cs b/ModernWpf.Controls/SplitView/SplitView.cs index e226e2b4..2220fbb2 100644 --- a/ModernWpf.Controls/SplitView/SplitView.cs +++ b/ModernWpf.Controls/SplitView/SplitView.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Windows; -using System.Windows.Controls; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; @@ -10,7 +9,7 @@ namespace ModernWpf.Controls { [ContentProperty(nameof(Content))] - public partial class SplitView : Control + public partial class SplitView : ControlEx { static SplitView() { diff --git a/ModernWpf.Controls/SplitView/SplitView.xaml b/ModernWpf.Controls/SplitView/SplitView.xaml index 67fc39ec..85d4a862 100644 --- a/ModernWpf.Controls/SplitView/SplitView.xaml +++ b/ModernWpf.Controls/SplitView/SplitView.xaml @@ -11,11 +11,14 @@ 0