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?
+10
A:
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;
codekaizen
2010-01-05 19:27:52
+1, but you need to cast the parameter because `Filter` is of type `Predicate<object>`
Thomas Levesque
2010-01-05 20:49:44
@Thomas - right, thanks. Edited.
codekaizen
2010-01-05 20:56:00
Thanks! Works great!
joek1975
2010-01-05 21:42:07