NOTE I have asked the related question: How to combine DataTrigger and EventTrigger?
I have a list box containing sever
For anyone else who's up against this problem, I found a solution that works for me. Of course, I'm still interested to see other interesting answers.
Here's what I did:
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding
RelativeSource={
RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},
Path=IsSelected}" Value="True"/>
<Condition Binding="{Binding IsAvailable}" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter TargetName="Name" Property="Foreground" Value="#F00"/>
</MultiDataTrigger>
There's nothing special about this being a multi trigger though. If you just wanted to style the selected item differently in your data template, you could use:
<DataTrigger Binding="{Binding
RelativeSource={
RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},
Path=IsSelected}" Value="True">
<Setter TargetName="Name" Property="Foreground" Value="#888"/>
</DataTrigger>
To use it with DataGridRow
change binding mode to Self
:
Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=...