如何在WPF ListView的过滤器? [英] How do I Filter ListView in WPF?

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

问题描述

我绑定到项目集合一个ListView。我不想显示其中属性请将isDeleted =1的项目。我怎样才能做到这一点?

I have a ListView bound to a collection of items. I do not want to show the items where the property IsDeleted = "1". How can I accomplish this?

推荐答案

我会使用一个的CollectionView和筛选器属性设置为前pression:

I'd use a CollectionView and set the Filter property to an expression:

var view = CollectionViewSource.GetDefault(GetData());
view.Filter = i => ((MyType)i).IsDeleted != 1;
MyListView.DataSource = view;

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

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