Button 样式设置

 1  <Style x:Key="ControlBtnStyle"  TargetType="{x:Type Button}">
 2             <Setter Property="Template">
 3                 <Setter.Value>
 4                     <ControlTemplate  TargetType="{x:Type Button}">
 5                         <Border x:Name="border"  BorderThickness="1" BorderBrush="Black" CornerRadius="0.5" 
 6                             HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="{TemplateBinding Padding}"
 7                             Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="DodgerBlue">
 8                             <Label x:Name="lbContent" Content="{TemplateBinding Content}" Background="Transparent" Height="{TemplateBinding Height}"
 9                                VerticalAlignment="Center" HorizontalAlignment="Center" FontFamily="宋体" FontSize="20" Foreground="White"/>
10                         </Border>
11                         <ControlTemplate.Triggers>
12                             <Trigger Property="IsMouseOver" Value="True">
13                                 <Setter Property="Background" TargetName="border" Value="{DynamicResource window_Button_MouseOver}"/>
14                                 <Setter Property="BorderThickness" TargetName="border" Value="2"/>
15                                 <Setter Property="FontSize" TargetName="lbContent" Value="22"/>
16                                 <Setter Property="Foreground" TargetName="lbContent" Value="Orange"/>
17                             </Trigger>
18                         </ControlTemplate.Triggers>
19                     </ControlTemplate>
20                 </Setter.Value>
21             </Setter>
22         </Style>

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注