tags:

views:

5

answers:

1

Hi 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

+2  A: 

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>
Heinzi
Thanks a lot that worked