I have a datagrid bound to a collection. I’ve applied the following rowstyle to the datagrid:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="Down">
<Setter Property="Background" Value="Red" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Status}" Value="Down" />
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsSelected}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="Green" />
<Setter Property="Foreground" Value="White" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
The datatrigger is working, but not the multidatatrigger. The condition that fails is the one that checks for IsSelected on the datagridrow being true. If I change it so it uses a valueconverter that always returns true I’ll see the rows as green.
Basically I want the rows whos data objects have the status property set to down to be red, but when I select those rows they need to be green (or darkred actually) instead of the default blue.
Your binding is propably perfectly fine. But the DataGrid is using the SystemColors.HighlightBrush and SystemColors.HighlightTextBrush to highlight selected rows. To change the color of the selected row you could just override the brush for your DataGrid like this:
This way you should be able to see the background color set by your trigger.
Hope this helps!