WPF-圆角按钮

来源:转载

 

重写Template制作的圆角按钮 右下角那个是按钮选中时的状态。

这个按钮制作是重写按钮的Template样式,改变圆角,只需要改变Template里面Border中CornerRadius的四个值。

代码如下:

<Button Content="地图" Height="50" Margin="555,282,466,393" Width="50"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="0" CornerRadius="3,13,3,13" Name="PART_Background"> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="White" Offset="0.0" /> <GradientStop Color="Silver" Offset="0.5" /> <GradientStop Color="White" Offset="0.0" /> </LinearGradientBrush> </Border.Background> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> <ControlTemplate.Triggers> <Trigger Property="UIElement.IsMouseOver" Value="True"> <Setter Property="Border.Background" TargetName="PART_Background"> <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> </Trigger> <Trigger Property="ButtonBase.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-%e5%9c%86%e8%a7%92%e6%8c%89%e9%92%ae/

分享给朋友:
您可能感兴趣的文章:
随机阅读: