The following example defines a Style that will be applied to every TextBlock element. This Style applies values to several TextBlock properties with the use of Setters.
|
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Segoe Black" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontSize" Value="12pt" />
<Setter Property="Foreground" Value="#777777" />
</Style>
|
The following example shows a named Style available to Button controls. The Style defines a Trigger element that changes the Foreground property of a button when the IsPressed property is true.
|
<Style x:Key="Triggers" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter Property = "Foreground" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
|