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?

Answers


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:

1.

. In your view model you create a list that contains all data obtained from a data source.

var myList = new List<string>();

2.

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.

3.

Bind your filtered list to the ItemsSource of the list view control.

Hence you can access to the items which are currently shown.


Need Your Help

How to add image in MATLAB GUI?

image matlab

I want to switch back and forth between two images, like blinking: 1 second for the first image and one second for second image.

I need to copy in reverse manner an array of longs I need a system function such as memcpy is there any?

c++ c memcpy

I need to copy from end to start an array of longs to an array of longs as is shown in the code bellow. Is there any function similar to memcpy for the required purpose ?