WPF-Path画的小关闭按钮

来源:互联网 时间:1970-01-01

用Path画的小关闭按钮

自定义按钮的Template,画一个小的关闭按钮。

<Button Width="16" Height="16"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="PART_Border" CornerRadius="0" BorderBrush="Black" BorderThickness="1" Padding="2"> <Path x:Name="PART_Path" Data="M6,6 L6,6 10,10 M10,6 L10,6 6,10" Fill="Gray" Stretch="Fill" Stroke="Gray" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" TargetName="PART_Border"> <Setter.Value> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="Silver" Offset="0.0" /> <GradientStop Color="White" Offset="0.5" /> <GradientStop Color="Silver" Offset="0.0" /> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="Stroke" TargetName="PART_Path" Value="#FFBA3232" /> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="UIElement.Effect"> <Setter.Value> <DropShadowEffect BlurRadius="10" Color="Black" Direction="0" Opacity="0.6" RenderingBias="Performance" ShadowDepth="0" /> </Setter.Value> </Setter> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template></Button>

原文地址:http://www.luacloud.com/2011/06/20/wpf-path%e7%94%bb%e7%9a%84%e5%b0%8f%e5%85%b3%e9%97%ad%e6%8c%89%e9%92%ae/

相关阅读:
Top