您的位置:首页 > 编程语言

WPF窗体无边框阴影效果-代码

2014-07-11 11:42 387 查看
资源字典:

<Style x:Key="NormalWinStyle" TargetType="{x:Type Window}">

<Setter Property="WindowStyle" Value="None" />

<Setter Property="AllowsTransparency" Value="True"/>

<Setter Property="Background" Value="{x:Null}"/>

<!--在Window中设置SnapsToDevicePixels属性值为True,子元素继承此值-->

<Setter Property="SnapsToDevicePixels" Value="True"/>

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type Window}">

<Border Background="#FFFFFF" CornerRadius="3" Margin="{TemplateBinding Padding}">

<!--设置窗体的阴影效果-->

<Border.Effect>

<DropShadowEffect ShadowDepth="0" BlurRadius="10" Opacity="0.75"/>

</Border.Effect>

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="Auto" />

<RowDefinition />

<RowDefinition Height="Auto" />

</Grid.RowDefinitions>

<Grid></Grid>

<!--使用AdornerDecorator装饰ContentPresenter-->

<AdornerDecorator Grid.Row="1">

<ContentPresenter></ContentPresenter>

</AdornerDecorator>

</Grid>

</Border>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

效果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: