WPF Listview filtered items
I have a listview which is filtered by the text entered by the user.
Is there anyway to get the visible items from the listview?
If you are using virtualization (or introduce it later), any solution which relies on the visible property of the list items may not return all the items which match your filter.
A more reliable solution might be to rerun the predicate against the underlying collection.
In order to achieve what you want, I propose the following solution:
. In your view model you create a list that contains all data obtained from a data source.
var myList = new List<string>();
Create a filtered list which is obtained whenever users enter a text, and you will filter your data based on the entered text.
var filteredList = myList.FindAll(myFilter);
where myFilter is a method to filter data based on some criteria.
Bind your filtered list to the ItemsSource of the list view control.
Hence you can access to the items which are currently shown.