I have the following HeaderTemplate defined in App.xaml:
<DataTemplate x:Key="ListViewGroupHeaderTemplate">
<TextBlock Foreground="Black" Text="Something" />
</DataTemplate>
I use it this way in my ListViewRenderer:
listView.ItemTemplate = App.Current.Resources["ListViewItemTemplate"] as Windows.UI.Xaml.DataTemplate;
var groupStyle = App.Current.Resources["groupStyle"] as GroupStyle;
listView.GroupStyle.Add(groupStyle);
The source of my ListView is a CollectionViewSource:
var source = new ObservableCollection<GroupItem>();
for (int i = 0; i < 10; i++)
{
var s = new GroupItem("Header " + i, "ShortName " + i);
for (int j = 0; j < 6; j++)
{
s.Add(new ListItem { Value = j, Text = "Text " + j });
}
source.Add(s);
}
CollectionViewSource cvs = new CollectionViewSource();
cvs.IsSourceGrouped = true;
List<ListItem> list = new List<ListItem>();
foreach (var item in source)
{
list.AddRange(item);
}
var group = from item in list group item by item.Value into grp orderby grp.Key select grp;
cvs.Source = group;
I've created a sample project and if I don't use the ListViewRenderer, I get this:
When I use it, I get this:
None of the group headers is rendered.
You can download the sample projects (working and not working) from here.
Can you tell me what is wrong with the ListViewRenderer?