How to set the BackgroundColor on a GridViewColumn in WPF!

So, you figured you would set the Grid or Border background color and it would work out? Then you ran your program and only the text was being filled in with your color right?

Well, the issue is two fold. First, you need to set the cell contents to stretch. Then you need to get past the fact the column pads the cell by 6 pixels left and right.

Handling the padding is here:

<Style TargetType="Border" x:Key="columnBorder">
                                <Setter Property="Margin" Value="-6,-2,-6,-6"/>
                                <Setter Property="Padding" Value="6,2,6,6"/>

</Style>

 

 

Set the HorizontalContentAlignment on the ListView or GridView.

Hope this helps.

I googled around for other entries and found this one with more detail than I wanted to write.

http://www.interact-sw.co.uk/iangblog/2007/05/30/wpf-listview-column-margins

Happy coding!