开发者

How do I Filter ListView in WPF?

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?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜