WPF圓角按鈕

圓角按鈕
重寫Template製做的圓角按鈕

右下角那個是按鈕選中時的狀態。spa

這個按鈕製做是重寫按鈕的Template樣式,改變圓角,只須要改變Template裏面Border中CornerRadius的四個值。code

代碼以下:orm

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
< 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 >
相關文章
相關標籤/搜索