- Define a style that will apply to all Button controls:
<Style TargetType="Button">
<Setter Property="FontSize" Value="18" />
<Setter Property="FontFamily" Value="Verdana" />
</Style>
The Button controls need not reference the style.
- Define a style that uses a key. Each Button control that wants to use
the style must reference the key.
<Style x:Key="MyStyle" TargetType="Button">
<Setter Property="FontSize" Value="18" />
<Setter Property="FontFamily" Value="Verdana" />
</Style>
This style will apply to all buttons that reference the style named MyStyle.
No control that is not a button can use the style.
- Define a style that uses a key, but that applies to all controls:
<Style x:Key="MyStyle" TargetType="Control">
<Setter Property="FontSize" Value="18" />
<Setter Property="FontFamily" Value="Verdana" />
</Style>
This style will apply to all controls that reference the key.