Tuesday, June 30, 2009

WPF : Hide Headers from a GridviewColumn


I know, this is simple but I wasted a bunch of my valuable time in finding a solution while developing my first application in WPF. Include the following line in your < listview> block to get rid of headers in your gridview column.

< ListView.Resources>
< Style x:Key="CustomHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
< Setter Property="Visibility" Value="Collapsed" />
< /Style>
< /ListView.Resources>



Joe said...

Great Tip, but it doesn't work as expected until you remove the x:Key attribute. Unless, of course, you want some headers visible and others not - which would make for a very odd ListView.

Vikas Bhandari said...

Thats correct. I actually meant to move to Window.Resources. That is why used the kay attribute :)

Thanks for pointing out though !!!