From 7d2cd793a0154580f1dd0c9685c461198e05f207 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Sat, 5 Oct 2019 05:39:44 +0200 Subject: [PATCH] Fix bug where shadow on NavigationView pane is missing (#1398) * Fix bug where shadow on NavigationView pane is missing * Update sizing and margin of shadow canvas * Apply suggestions from code review Co-Authored-By: Kai Guo * Fix bug where regeression page would crash * Update visual tree verification file --- dev/NavigationView/NavigationView.cpp | 15 ++++++++++++++- .../master/NavigationView-8.xml | 5 +++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dev/NavigationView/NavigationView.cpp b/dev/NavigationView/NavigationView.cpp index 4af65e6362..2a8f928a3f 100644 --- a/dev/NavigationView/NavigationView.cpp +++ b/dev/NavigationView/NavigationView.cpp @@ -3594,6 +3594,12 @@ void NavigationView::UpdatePaneShadow() if (auto contentGrid = GetTemplateChildT(c_contentGridName, *this)) { contentGrid.SetRowSpan(shadowReceiver, contentGrid.RowDefinitions().Size()); + contentGrid.SetRow(shadowReceiver, 0); + // Only register to columns if those are actually defined + if (contentGrid.ColumnDefinitions().Size() > 0) { + contentGrid.SetColumn(shadowReceiver, 0); + contentGrid.SetColumnSpan(shadowReceiver, contentGrid.ColumnDefinitions().Size()); + } contentGrid.Children().Append(shadowReceiver); winrt::ThemeShadow shadow; @@ -3611,9 +3617,16 @@ void NavigationView::UpdatePaneShadow() } } + // Shadow will get clipped if casting on the splitView.Content directly // Creating a canvas with negative margins as receiver to allow shadow to be drawn outside the content grid - winrt::Thickness shadowReceiverMargin = { -CompactPaneLength(), -c_paneElevationTranslationZ, -c_paneElevationTranslationZ, -c_paneElevationTranslationZ }; + winrt::Thickness shadowReceiverMargin = { 0, -c_paneElevationTranslationZ, -c_paneElevationTranslationZ, -c_paneElevationTranslationZ }; + + // Ensuring shadow is aligned to the left + shadowReceiver.HorizontalAlignment(winrt::HorizontalAlignment::Left); + + // Ensure shadow is as wide as the pane when it is open + shadowReceiver.Width(OpenPaneLength()); shadowReceiver.Margin(shadowReceiverMargin); } } diff --git a/test/MUXControlsTestApp/master/NavigationView-8.xml b/test/MUXControlsTestApp/master/NavigationView-8.xml index 9f50776ca5..045a874b11 100644 --- a/test/MUXControlsTestApp/master/NavigationView-8.xml +++ b/test/MUXControlsTestApp/master/NavigationView-8.xml @@ -2124,14 +2124,15 @@ RenderSize=120,19 [Windows.UI.Xaml.Controls.Canvas] Background=[NULL] + Width=120 Name=PaneShadowReceiver - Margin=-40,-32,-32,-32 + Margin=0,-32,-32,-32 FocusVisualSecondaryThickness=1,1,1,1 FocusVisualSecondaryBrush=#99FFFFFF FocusVisualPrimaryThickness=2,2,2,2 FocusVisualPrimaryBrush=#FF000000 Visibility=Visible - RenderSize=72,664 + RenderSize=120,664 [Windows.UI.Xaml.Shapes.Rectangle] StrokeThickness=1 Name=LightDismissLayer