tags:

views:

288

answers:

2

I can create simple triggers that check if a property has a specific value like this:

<Style x:Key="StatusIndicator" TargetType="TextBlock">
    <Style.Triggers>
        <DataTrigger Binding="{Binding Status}" Value="off">
            <Setter Property="TextBlock.Foreground" Value="Red"/>
        </DataTrigger>
    </Style.Triggers>
</Style>

But how would I use any more complicated operators, e.g.:

PSEUDO-CODE:

<DataTrigger Binding="{Binding Amount}" Operator=">=" Value="35">
    <Setter Property="TextBlock.Foreground" Value="Red"/>
</DataTrigger>

Is there some property like "Operator", or do I need to use a converter for this or how are complex operators realized in triggers?

+1  A: 

You can't have complex operators in triggers. A converter is a good way to go; perhaps from int to bool for your example, or int to enum if there are mare than two states.

I don't think you'd want to embed complex logic in XAML. It wouldn't take long to become a maintenance nightmare.

AndrewS
A: 

The operator support is very convenient. We plan to add it in eclipse XWT

Yves YANG