tags:

views:

2165

answers:

1

How to provide multiple conditions for data trigger in WPF?

+6  A: 

Use MultiDataTrigger type

<Style TargetType="ListBoxItem">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Path=State}" Value="WA">
        <Setter Property="Foreground" Value="Red" />
      </DataTrigger>    
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=Name}" Value="Portland" />
          <Condition Binding="{Binding Path=State}" Value="OR" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Background" Value="Cyan" />
      </MultiDataTrigger>
    </Style.Triggers>
  </Style>
Gishu
Is there a way to do an "OR" statement in the multiTrigger. e.g. the name = "portland" OR the state = "OR"
jasonk
@jasonk - Not sure if you can do that with a MultiTrigger. You can define two triggers for that..
Gishu