Skip to content

Commit

Permalink
Fix bug where shadow on NavigationView pane is missing (#1398)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Fix bug where regeression page would crash

* Update visual tree verification file
  • Loading branch information
marcelwgn authored and kaiguo committed Oct 5, 2019
1 parent 45c12e5 commit 7d2cd79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 14 additions & 1 deletion dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3594,6 +3594,12 @@ void NavigationView::UpdatePaneShadow()
if (auto contentGrid = GetTemplateChildT<winrt::Grid>(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;
Expand All @@ -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);
}
}
5 changes: 3 additions & 2 deletions test/MUXControlsTestApp/master/NavigationView-8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d2cd79

Please sign in to comment.