1 if you select the cell, set row background on a white colour
and
2 if you select the cell and row background is yellow, does not change the row background
I write this code for first condition, but I don't know how to make for first and second conditions together. Maybe I need a MultiTrigger ? :
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="White" />
<Setter Property="Foreground"
Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
I guess you are setting background to
White
since you have overridenHighlightBrushKey
to Transparent and selecting cell hides the cell content. So, setting Foreground to Black i guess is sufficient there. That ways you don't have to worry about not updating background of cell with background yellow already.But, however still you want to do that, you can do that using single
MultiDataTrigger
where you need to check if background of dataGridRow is Yellow, then do nothing. But since you want to do that unless background is Yellow color, use IValueConverter to see if background is other than Yellow.and converter will be: