你不能简单地给Pane
的直接孩子涂上阴影,因为它会被截断。当然,你可以尝试重写SplitView
的风格和应用的影子直接到Pane
元素,但你很快就会发现,在PaneRoot
都有自己剪辑在XAML定义逻辑,所以如果你不小心,你可能会破坏其底层的UI逻辑。
这是一个简单的解决方案,不需要修改样式。这个想法是将阴影应用在内部元素上,在这个元素和Pane
的根元素之间有足够的空间来扩散阴影。
假定PanePlacement
设置为Right
,那么你的根元素,一个Border
(即RootBorder
),应该有一个左填充(即12,0,0,0
)该DropShadowPanel
的匹配BlurRadius
(即12
)。
另外,PaneBackground
需要透明否则它会掩盖影子。相反,背景颜色应该应用于根元素内的容器元素(即PaneContentGrid
)。
请参阅下面一个简单的例子代码 -
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>
演示
貌似已经问问题或这个HTTPS的复制: //stackoverflow.com/questions/43395093/how-to-add-a-drop-s hadow-for-splitview-pane –
[如何为SplitView.Pane添加投影]可能的重复(https://stackoverflow.com/questions/43395093/how-to-add-a-drop-shadow-for- splitview-pane) –
你错过了这个人问的问题,我会引用:_但是,阴影出现在窗格内,而我希望它在SplitView.Pane之外,将它包裹起来。我怎样才能实现呢?谢谢!_ –