如何在WPF中订购组 [英] How can I order Groups in WPF

查看:63
本文介绍了如何在WPF中订购组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

<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。添加两个sort descriptions允许我们首先对组进行排序,然后对其中的项目进行排序

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

在此处了解更多信息

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

这篇关于如何在WPF中订购组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆