[ACCEPTED]-How can I get this DataTrigger to work?-datatrigger
Accepted answer
Allow me to answer this one, I had forgotten 2 to wrap it all in a style, then it works 1 nicely:
<TextBox
Width="200"
Text="{Binding FieldEmail, UpdateSourceTrigger=PropertyChanged}">
<TextBox.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding FieldEmailValidationStatus}" Value="invalid">
<Setter Property="TextBox.Background" Value="Tomato"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
or this:
<Style x:Key="FieldEmailStyle" TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding FieldEmailValidationStatus}" Value="invalid">
<Setter Property="TextBox.Background" Value="Yellow"/>
</DataTrigger>
<DataTrigger Binding="{Binding FieldEmailValidationStatus}" Value="valid">
<Setter Property="TextBox.Background" Value="LightGreen"/>
</DataTrigger>
</Style.Triggers>
</Style>
<TextBox
Width="200"
Style="{StaticResource FieldEmailStyle}"
Text="{Binding FieldEmail, UpdateSourceTrigger=PropertyChanged}">
</TextBox>
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.