As you have rightly identified, the
ObservableCollection
is not quite the right tool for the job here, so what do you do? Well, fortunately for us, WPF provides something called the
CollectionView
which you can think of as a wrapper around a collection. In order to use it, expose the item that you want to bind on as an
ICollectionView
item like this:
public ICollectionView MyView { get; private set; }
Now, you fill it like this:
IList<Person> people = GetPeople();
MyView = CollectionViewSource.GetDefaultView(people);
Finally, you just need to filter the data (using whatever algorithm you need to filter this list on) and then update the
ICollectionView
using
MyView.Refresh();