Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I order Groups in WPF

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?

like image 710
user380719 Avatar asked Jan 20 '11 12:01

user380719


1 Answers

<CollectionViewSource x:Key="cvs" Source="{Binding Source={StaticResource animals}, Path=AnimalList}">
    <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="Category"/>
    </CollectionViewSource.GroupDescriptions>
    <CollectionViewSource.SortDescriptions>
        <scm:SortDescription PropertyName="Category" />
        <scm:SortDescription PropertyName="Name" />
    </CollectionViewSource.SortDescriptions>
</CollectionViewSource>

Just add two SortDescriptions.Adding two sort descriptions allows us to sort the groups first and then the items within the groups.

For more check here

http://bea.stollnitz.com/blog/?p=17

like image 191
biju Avatar answered Sep 30 '22 19:09

biju