I have a ListView which might contains a lot of items, so it is virtualized and recycling items. It does not use sort. I need to refresh some value display, but when there are too many items, it is too slow to update everything, so I would like to refresh only the visible items.
How could I get a list of all currently displayed items ? I tried to look into the ListView or in the ScrollViewer, but I still have no idea how to achieve this. The solution must NOT go through all items to test if they can be seen, because this would be too slow.
I'm not sure code or xaml would be useful, it is just a Virtualized/Recycling ListView with its ItemSource bound to an Array.
Edit :
Answer :
thanks to akjoshi, I found the way :
get the
ScrollViewerof theListView(with aFindDescendantmethod, that you can do yourself with theVisualTreeHelper).read its
ScrollViewer.VerticalOffset: it is the number of the first item shown- read its
ScrollViewer.ViewportHeight: it is the count of items shown.
Rq :CanContentScrollmust be true.