Reputation: 8474
I have following collection view
<CollectionViewSource x:Key="messages" Source="{Binding src}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Group"/>
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
Then I assign it to TreeView's ItemsSource. Now, how to sort Groups by their name? They appear to have random order.
Upvotes: 5
Views: 3954
Reputation: 18168
Just sort by the group. This should work:
<CollectionViewSource x:Key="messages" Source="{Binding src}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Group"/>
</CollectionViewSource.GroupDescriptions>
<CollectionViewSource.SortDescriptions>
<SortDescription PropertyName="Group" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
Upvotes: 7