在一个ObservableCollection的筛选和排序ListView控件,绑定 [英] Filtering and Sorting of an ObservableCollection in ListView-Binding

查看:1459
本文介绍了在一个ObservableCollection的筛选和排序ListView控件,绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET程序,你可以使用类似

In earlier Versions of .net you could use something like

ICollectionView collectionView = CollectionViewSource.GetDefaultView(AllImages);

要建立过滤机制UI元素。但是,这似乎并没有在WinRT的存在了。

To build up filter mechanisms for UI-Elements. But this doesn't seem to exist in WinRT anymore.

我使用一个列表框,元素显示一个用户列表。
用户一流的包含属性的用户名(字符串),isOnline(布尔),isFriend(布尔)和unreadMails(INT)。我需要某种形式的过滤和排序的。

I'm using a ListBox-Element to display an User-List. The User-Class contains the properties username (String), isOnline (Boolean), isFriend (Boolean) and unreadMails (Int). I need some kind of Filtering and sorting.

过滤:


  • 无过滤器

  • 只有isOnline ==由真实

订单:


  • unreadMails> 0

  • unreadMails == 0

    • 和isOnline ==真

      • 和isFriend ==真

      • isFriend ==虚假


      • 和isFriend ==真

      • 和isFriend ==虚假

      运行时,性能可能会改变,这将是冷静,如果列表自动更新。 (绑定已经工作,只有过滤器和秩序缺失)。

      The properties may change while running, it would be cool if the list updates itself automatically. (Binding is already working, only the filter and order is missing).

      任何想法如何实现这一目标?

      Any Ideas how to achieve this?

      推荐答案

      正如你想通了CollectionViewSource没有在WinRT中/ XAML过滤器或排序支持。您的解决方案然后到相关的ObservableCollection的内容进行排序。

      As you'd figured out the CollectionViewSource doesn't have support for filters or sorts in WinRT/XAML. Your solution is then to sort the contents of the associated ObservableCollection.

      这篇关于在一个ObservableCollection的筛选和排序ListView控件,绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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