C# – How to set the color of a selected row in DataGrid


The default background color of a selected row in DataGrid is so dark that I can't read it. Is there anyway of overriding it?

Tried this

    <Style TargetType="{x:Type dg:DataGridRow}">
            <Trigger Property="IsSelected" Value="True" >
                <Setter Property="Background" Value="Gainsboro" />

But still nothing…

Best Solution

The above solution left blue border around each cell in my case.

This is the solution that worked for me. It is very simple, just add this to your DataGrid. You can change it from a SolidColorBrush to any other brush such as linear gradient.

  <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" 
Related Question