Well, I have seen this code to do that:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="Green">
</Setter>
</Trigger>
</Style.Triggers>
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource ucComponentesColorFilaMultiValueConverter}">
<Binding ElementName="dgdComponentes" Path="ItemsSource" />
<Binding ElementName="dgdComponentes" Path="SelectedItems" />
<Binding ElementName="CurrentItem" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</DataGrid.RowStyle>
Really the code is the style trigger, the setter property is for other cases, but I add the code of this can affect to the result.
I would like to change the selected row background, that by default is blue, and I want to other color according to some conditions. For example, if a register is added, then if I select the row it would be green, if this row is unselected, it would be light green.
I am be able to change the color of the rows as I want, but when I select it, always is blue.
Thanks.
You can try something like this maybe...
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With