user9969
user9969

Reputation: 16040

Conditional Trigger is it possible?

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

Answers (1)

Heinzi
Heinzi

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

Related Questions