July 2017
Beginner
466 pages
9h 37m
English
As the name suggests, the data trigger applies a property value to perform a set of actions on the data that has been bound to the UI element. This is represented by the <DataTrigger> element.
Here's an example of writing a data trigger to a UI element:
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<CheckBox Name="chkError" Content="Error"
VerticalAlignment="Center"/>
<TextBlock Margin="20, 0" FontSize="50">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="Pass" />
<Setter Property="Foreground" Value="Green" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=chkError, Path=IsChecked}" Value="True"> <Setter Property="Text" Value="Fail" ...Read now
Unlock full access