Im very new to WPF and i am working with ListView and Grouping.
What im trying to achieve is to group items by certain type but display a different name on the ListView header. This will allow me to have 2 different group types with the same name
Heres my code so far
//.....Populate dummy items in a loop
items.Add(new Beds() { Name = "Bed " + counter, Type = i.ToString() , TypeName = "Test Name" });
//....
lvBeds.ItemsSource = items;
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lvBeds.Items);
PropertyGroupDescription groupDescription = new PropertyGroupDescription("Type");
view.GroupDescriptions.Add(groupDescription);
XAML
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock FontWeight="Bold" FontSize="20" Text="{Binding TypeName}" Background="Gray" Height="35"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
I want to map the ListView Header TextBlock Text to "TypeName" while keeping the grouping to "Type". Is that possible?
Edit: I solved this by using IValueConverter to handle the replacement of binding name string.