开发者

How do I Filter ListView in WPF?

开发者 https://www.devze.com 2022-12-15 07:42 出处:网络
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 F

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

精彩评论

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