I want to be able to hide the header at the top of each grid column in a WPF ListView.
This is the XAML for my ListView:
Define a Style like so
<Window.Resources>
....
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</Window.Resources>
Apply it like so
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}">
....
</GridView>
Another way you can apply Ray's solution is like this:
<ListView>
<ListView.View>
<GridView>
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</GridView.ColumnHeaderContainerStyle>
</GridView>
</ListView.View>
</ListView>
The solution sets the style property directly rather than creating a resource that is automatically applied. Not saying it's better, just another way...
Thanks for this solution. You can also put the Style
inline like so:
<ListView>
<ListView.Resources>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<!-- ... -->
</GridView>
</ListView.View>
</ListView>
(Also, the {x:Type}
notation you used doesn't seem to be needed)