WPF - Style的例子

<Window.Resources>

    <Style TargetType="CheckBox">

      <Setter Property="Height" Value="20"/>

      <Setter Property="Width" Value="50"/>

      <EventSetter Event="Checked" Handler="Checked_Click"/>

      <Setter Property="VerticalAlignment" Value="Center"/> 

    </Style>    

</Window.Resources>
 
继承
<Style BasedOn="{StaticResource {x:Type CheckBox}}"

           TargetType="CheckBox"

           x:Key="WiderCheckBox">

      <Setter Property="Width" Value="70"/>

</Style>
 
使用

<CheckBox Style="{StaticResource WiderCheckBox}">Win</CheckBox>

你可能感兴趣的:(style)