为无边框窗口设置阴影效果
2014-10-09 15:43
561 查看
需要将窗口样式添加到 App.xaml 中
窗体中
<Style x:Key="for_noresize_window_CLeopard" TargetType="{x:Type Window}"> <Setter Property="AllowsTransparency" Value="true"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="FontFamily" Value="Consolas, Microsoft YaHei"/> <Setter Property="FontSize" Value="24"/> <Setter Property="ResizeMode" Value="NoResize"/> <Setter Property="WindowStyle" Value="None"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Window}"> <Grid Margin="10"> <Rectangle Fill="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" RadiusX="5" RadiusY="5"> <Rectangle.Effect> <DropShadowEffect BlurRadius="10" ShadowDepth="0"/> </Rectangle.Effect> </Rectangle> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Margin}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CornerRadius="5"> <ContentPresenter /> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
窗体中
<Window x:Class="CLeopard.Windows.NoResizeWithShadowEffect" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Transparent" Height="500" Width="500" Title="NoResizeWithShadowEffect" WindowStartupLocation="CenterScreen" Style="{StaticResource for_noresize_window}"> <Grid> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <Label Content="NoResizeWithShadowEffect" Foreground="Olive"/> <TextBlock Text=""/> <Button Padding="20,5" Content="Close Window" Click="Clicked"/> <x:Code> <![CDATA[ void Clicked(object sender, RoutedEventArgs e) { this.Close(); } ]]> </x:Code> </StackPanel> </Grid> </Window>
相关文章推荐
- [WPF] 如何为无边框窗口设置阴影效果
- [WPF] 如何为无边框窗口设置阴影效果
- [WPF] 如何为无边框窗口设置阴影效果
- 设置边框阴影效果
- pyqt实现窗口边框阴影效果(python)
- 设置边框效果和阴影层
- 黄聪:CSS+DIV 设置圆角边框加阴影效果
- WPF 窗口边框阴影效果
- css中设置边框阴影效果
- 好玩的WPF第一弹:窗口抖动+边框阴影效果+倒计时显示文字
- CSS+DIV 设置圆角边框加阴影效果
- C# WinForm无边框窗体设置阴影效果
- css3阴影设置发光边框效果
- 为View设置边框阴影效果
- mfc如何快速实现无边框窗口阴影效果
- 好玩的WPF第一弹:窗口抖动+边框阴影效果+倒计时显示文字
- 设置ul阴影效果和边框圆角
- QSS控件的边框阴影效果和四个角的圆角设置
- 无边框窗口实现拖垃效果
- C# 边框阴影窗体效果