Reputation: 33
I am currently trying to create a SplitView.Pane that looks kinda like the edge browser history/favourites pane. Therefore, I need a shadow at the (left) border of my SplitView.Pane.
To create the shadow, I use the DropShadowPanel from the UWP Toolkit. The idea is something like this (doesn't work, of course):
<controls:DropShadowPanel>
<SplitView.Pane>
<!--Content-->
</SplitView.Pane>
</controls:DropShadowPanel>
The shadow should be outside the panel. How do I get this done?
This is how the shadow should look like:
EDIT: The DropShadow should be OUTSIDE the pane. The duplicate-post's answer creates a shadow inside the pane. Unless i miss something there.
Upvotes: 3
Views: 1288
Reputation: 39006
You can't simply apply a shadow to the Pane
's direct child as it will appear being cut off. You can of course try overriding the SplitView
's style and applying the shadow directly onto the Pane
element, but you will soon find out that the PaneRoot
has its own Clipping logic defined in XAML, so if you were not careful, you could potentially break its underlying UI logic.
Here's a simple solution that works without modifying the style. The idea is to apply the shadow on an inner element where there's enough space between this element and the Pane
's root element for the shadow to spread out.
Assume the PanePlacement
is set to Right
, then your root element, a Border
(i.e. RootBorder
), should have a left padding(i.e. 12,0,0,0
) that matches the BlurRadius
(i.e. 12
) of the DropShadowPanel
.
Also, the PaneBackground
needs to be transparent otherwise it will cover up the shadow. Instead, the background color should then be applied to a container element(i.e. PaneContentGrid
) that's inside the root element.
Please see the code below for a simple example -
XAML
<SplitView PanePlacement="Right" PaneBackground="Transparent">
<SplitView.Pane>
<Border x:Name="RootBorder" Padding="12,0,0,0">
<Grid>
<controls:DropShadowPanel BlurRadius="12"
Color="Black"
Opacity="0.3"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch">
<Rectangle Fill="White" />
</controls:DropShadowPanel>
<!-- SystemControlPageBackgroundChromeLowBrush is the default PaneBackground brush, feel free to change it to whatever you like! -->
<Grid x:Name="PaneContentGrid" Background="{ThemeResource SystemControlPageBackgroundChromeLowBrush}">
<!-- place your Panel content here. -->
</Grid>
</Grid>
</Border>
</SplitView.Pane>
</SplitView>
Demo
Upvotes: 4