WPF弹出窗口阴影未显示。

15

我希望在我的项目中为弹出层设置阴影,但运行后阴影没有出现。这是我编写的代码:

    <Popup x:Name="popup" IsOpen="False"   Width="200" Height="200" Placement="AbsolutePoint" AllowsTransparency="True" PopupAnimation="Fade"   >
        <Grid>
            <Border  BorderThickness="1" Background="#FF4CAAC7" CornerRadius="6" >
                <Border.Effect>
                    <DropShadowEffect BlurRadius="15" Opacity="0.8"  ShadowDepth="10" Direction="-90" RenderingBias="Quality" />
                </Border.Effect>
                <StackPanel Orientation="Horizontal">
                    <Grid Width="200" Background="Transparent">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" FontWeight="Bold" TextAlignment="Right" Margin="10">Operation was successful</TextBlock>
                    </Grid>
                </StackPanel>
            </Border>
        </Grid>
    </Popup>

在设计中,阴影显示正常,在运行时却不显示。问题出在哪里?!!

1个回答

16
Popup的内侧边缘,阴影被裁剪掉了。通过给边框足够的边距来为阴影腾出空间,为其在Popup中创造更多的空间。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接