Reputation: 16040
I have a situation where I need to check a property "HasDelivered" if true. the foreground color of my textBlock should be green else red.
Any ideas or suggestions
Upvotes: 0
Views: 3540
Reputation: 172280
Use a style with a data trigger:
<TextBlock ...>
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding HasDelivered}" Value="True">
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Upvotes: 2