I'm aware that I can group items in a ComboBox by creating a ListCollectionView in code and setting a GroupDescription.
I'm wondering if there's a way to avoid using code behind, by populating the ListCollectionView directly in XAML.
In my case, the ComboBox has a fixed list of elements with DynamicBindings in them. So it would be easier for me to stay in XAML.
Here's the simplified example:
<UserControl.Resources>
<x:Array x:Key="ExportItemArray" Type="{x:Type i:ExportItem}">
<i:ExportItem Name="Audio" Description="WAV"/>
<i:ExportItem Name="Image" Description="PNG Image"/>
<i:ExportItem Name="Video" Description="Mp4 Video"/>
</x:Array>
<CollectionViewSource x:Key="CollectionViewSource" Source="{Binding ExportItemArray}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Name"/>
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</UserControl.Resources>
<ComboBox ItemsSource="{StaticResource CollectionViewSource}">
<ComboBox.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ComboBox.GroupStyle>
</ComboBox>
The CollectionViewSource is not being accepted by the ComboBox, since it's a proxy type of CollectionView instead of ListCollectionView.
I'm not sure if there's any proxy for ListCollectionView.