This is just a quick note on creating a ListView style with the appropriate GridView style and template assignments.
Normally, I’ve been creating listviews that look like this:
<ListView x:Name=”MyListView”
ItemContainerStyle=”{DynamicResource MyListViewItemContainerStyle}”>
<ListView.View>
<GridView ColumnHeaderContainerStyle=”{DynamicResource MyListViewHeaderStyle}”
ColumnHeaderTemplate=”{DynamicResource MyGridColumnHeaderTemplate}”>
I did this because I didn’t know exactly how to assign these styles and templates to the ListView Style. In the style, ColumnHeaderContainerStyle and ColumnHeaderTemplate are not properties of the ListView, they are properties of the GridView… which you can’t create a style for.
Instead, you can encapsulate all the information above in the following style.
<Style x:Key=”CustomListViewStyle” TargetType=”{x:Type ListView}”>
<Setter Property=”GridView.ColumnHeaderContainerStyle” Value=”{DynamicResource MyListViewHeaderStyle}” />
<Setter Property=”GridView.ColumnHeaderTemplate” Value=”{DynamicResource MyGridColumnHeaderTemplate}” />
<Setter Property=”ItemContainerStyle” Value=”{DynamicResource MyListViewItemContainerStyle}” />
</Style>
Problem solved.