tags:

views:

467

answers:

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?

+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
+1, but you need to cast the parameter because `Filter` is of type `Predicate<object>`
Thomas Levesque
@Thomas - right, thanks. Edited.
codekaizen
Thanks! Works great!
joek1975