1

有没有办法让 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>
4

1 回答 1

5

您可以Panel.ZIndex="0"在每个边框中使用直接从 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>

或者,StackPanel.SetZIndex(object, value)如果您想从代码中执行此操作,则可以使用。

于 2009-10-15T11:45:47.183 回答