.Net Maui Slow Loading CollectionView and UI Tree structure

1.8k Views Asked by At

So I set out to do a simple interface with a search field, a couple of "tabs" that represent data categories and a CollectionView to show the data as the figure below

enter image description here

During development I noticed that when I set a tab that had more data, the loading would take a longer time (too long), and everything would kind of get stuck waiting for it to respond, so I started making some tests on how the CollectionView gets populated (via the ChildAdded event) and here are my findings

In most cases the CollectionView will load Childs that fit in the view (in my screenshot for example it would only load 4 children), and everytime you scroll it will load the appropriate number of items to fill the screen. This happened when the collection only had this types of ancestor Elements - ContentPage, Frame, RefreshView. ScrollView, TableView, Grid (if not set to Auto), HorizontalStackLayout, FlexLayout, toolkit:DockLayout

However there are other cases where all the childs are loaded right away, this happens when the CollectionView is the descendant of this types - ScrollView, VerticalStackLayout, StackLayout, AbsoluteLayout, Grid (when set to auto)

Does anyone have any idea why this happens?

Also is it possible to make it load a fixed number of Children each time, let's say instead of loading enough items to fill the View I want to load 10 items (note that loading the data incrementally with RemainingItemsThresholdReachedCommand for example, only loads the data into memory, and doesn't create a child item in the View)

Note this tests are not exhaustive and there can be other combinations of ancestors/configurations that have different results, and they where only done with Android emulator

0

There are 0 best solutions below