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"/>




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.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.