Recently, I was having issues trying to figure out how to change the WPF DataGrid’s highlighted row background color. After some digging and trial and error I figured out that it apparently uses the SystemColors. To change the color, I created a SolidColorBrush that had the key set to SystemColors.HightlightBrushKey and specified the color I wanted.

Shows WPF DataGrid with standard highlight row.

 

Shows WPF DataGrid with Highlight row changed.

One thing to note is this is also the same key that’s used in the WPF ComboBox for highlighting rows in the drop-down portion. So if you only want this on the DataGrid only, specify it in the DataGrid’s Resources section.

Bonus!!!
If you change in the above listed code HighlightBrushKey to HighlightTextBrushKey and set Color to Black it will change the font of the highlighted row to show black.

WPF DataGrid with Highlight row brush and text set.

 

Like this post? Share it!