Pau*_*ulo 1 wpf shadow stackpanel
有没有办法让 StackPanel 中第一个控件的阴影出现在第二个控件的顶部?我有这个问题,看图!
替代文字 http://img2.imageshack.us/img2/7073/issuef.png
代码示例:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Grid>
<StackPanel>
<Border Height="100" Width="100" Background="Red">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="1" Softness="2" />
</Border.BitmapEffect>
</Border>
<Border Height="100" Width="100" Background="blue">
</Border>
</StackPanel>
</Grid>
</Page>
Run Code Online (Sandbox Code Playgroud)
您可以Panel.ZIndex="0"在每个 Borders 中使用直接从 XAML 设置项目的 z 顺序。
<StackPanel>
<Border Height="100" Width="100" Background="Red" Panel.ZIndex="1">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="1" Softness="2" />
</Border.BitmapEffect>
</Border>
<Border Height="100" Width="100" Background="blue" Panel.ZIndex="0">
</Border>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
或者,StackPanel.SetZIndex(object, value)如果您想从代码中执行此操作,则可以使用。
| 归档时间: |
|
| 查看次数: |
11268 次 |
| 最近记录: |