场景: wpf 要实现一个窗口 四边有阴影,如图
但是如果只是像放在窗口上的 控件加阴影效果,可以用如下示例实例
<DropShadowEffect BlurRadius="24" Color="#FF858484" Direction="90" ShadowDepth="3"/>
但是对于窗口,如果单是如此加就达不到效果,因为阴影已经超出了窗口的东西。
解决方案:
<Window x:Class="VOP.Controls.MessageBoxEx_Simple"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MessageBoxEx_Simple"
Height="158" Width="478"
BorderThickness="24"
AllowsTransparency="True"
WindowStyle="None"
ResizeMode="NoResize"
xmlns:local="clr-namespace:VOP.Controls"
xmlns:mycontrol="clr-namespace:VOP"
ShowInTaskbar="False"
VerticalAlignment="Center"
WindowStartupLocation="CenterOwner"
>
<Window.Effect>
<DropShadowEffect BlurRadius="24" Color="#FF858484" Direction="90" ShadowDepth="3"/>
</Window.Effect>
注意 加上这几行 Height="158" Width="478"
BorderThickness="24"
,其中的Width, Height 已经在原来的基础上加了 48。