The Source property in CollectionViewSource must implement the IGrouping interface, otherwise the groups will not work in the GridView or ListView.
Either use the Linq GroupBy expression to group the results into groups with the specified key, or you can extend the ObservableCollection class as follows:
public class GroupedObservableCollection<T> : ObservableCollection<T>, IGrouping<string, T> {
and use it in my class (I have a CollectionViewSource in ViewModel, not in XAML):
public GroupedObservableCollection<DataItem> Items groupedItemsViewSource = new CollectionViewSource { Source = AllGroups, ItemsPath = new PropertyPath("Items"), IsSourceGrouped = true };
This way the binding will work. Also make sure you use the correct bindings in ListView and GridView:
<GridView ItemsSource="{Binding groupedItemsViewSource.View}" ... /> <GridView ItemsSource="{Binding groupedItemsViewSource.View.CollectionGroups}" ... />
source share