In WPF, the CollectionViewSource allows for sorting (SortDescriptions) and grouping (GroupDescriptions). However, I can\'t find a way to order the groups. Is it possible?
Groups sorting is possible though it's not so straightforward. I'll explain it on the example.
class CollectionElement
{
public string Name {get; set; }
public string Group {get; set; }
}
If you wish to group elements and sort the groups alphabetically then sort elements within each group alphabetically then you should do the following:
Group propertyGroupNameThe grouping process seems to work effectively like the following way: Iterate through already sorted elements consequently. When encountering element form unknown group - create a group and add it to groups list. When encountering element from existing group - add it to the existing group. (Actual implementation may be different). So if your elements are sorted in the order you wish your groups to appear you will effectively sort the groups.