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
2009-05-25 08:53:22
Is there a way to do an "OR" statement in the multiTrigger. e.g. the name = "portland" OR the state = "OR"
jasonk
2010-06-28 21:28:22
@jasonk - Not sure if you can do that with a MultiTrigger. You can define two triggers for that..
Gishu
2010-06-29 05:40:22