Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

ListView Virtualization for Loading on Scroll

$
0
0

Hello all!

So I'm trying to figure out how to allow for loading individual cells as you scroll through a listview. I have a database with thousands of items, and so I don't want all of them to load at once, but only load each cell as you scroll down.

I was thinking of using the ItemAppearing for ListViews, but it seems that you get the "item" which is the cell rather than any sort of index to go and grab the right item. Also, at least for iOS. ItemAppearing seems to get called on every single item in the list first, then on those that are actually there on screen (I believe this is a bug... i.e. if you make the source an Enumerable of many integers, creating the ListView will call ItemAppearing on all of the integers, and then the 10-11 items on the actual screen).

The only method that seems to index into the ListView is to override the SetupContent method, but it seems that only gets called at creation in the beginning and not as they are created when you scroll down or up.

Does anyone have a solution for this that doesn't involve rendering the entire listview in iOS and Android individually? It seems like the idea of indexing would be difficult given that the source is held as an IEnumerable (which if someone from Xamarin could answer why that design choice is the case, that would be greatly appreciated!). And if not, could someone maybe recommend a semi-elegant solution for loading items from database into a ListView?

Thank you so much!


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>