在WPF中,CollectionViewSource允许排序(SortDescriptions)和分组(GroupDescriptions)。但是,我找不到订购组的方法。可能吗?

最佳答案

<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>


只需添加两个SortDescriptions,添加两个排序描述就可以先对组进行排序,然后对组中的项目进行排序。

在这里查看更多

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

关于wpf - 如何在WPF中订购组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4747130/

10-12 22:17