I have a ListBox
with binding to a list of strings. I want to filter the list when I enter text in a TextBox
. How can I do it?
publ
CollectionViewSource class can help here. As far as I can tell it has many capabilities to filter, sort and group collections.
ICollectionView view = CollectionViewSource.GetDefaultView(ElementList);
view.Filter = (o) => {return o;}//here is the lambda with your conditions to filter
When you don't need any filter just set view.Filter
to null
.
Also check out this article on filtering