enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
1.16k stars 137 forks source link

More then 1000 of children binding in Treeview #436

Open IMAZHARQ opened 1 year ago

IMAZHARQ commented 1 year ago

I am using the Maui window. Treeview is working fine for a minimum of records. but when more than 3,000 child records i am binding it does not respond. Help to bypass this issue.

enisn commented 1 year ago

You can use lazy-loading. TreeView supports lazy-loading children on demand. You can bind LoadChildrenCommand in TreeView.

https://enisn-projects.io/docs/en/uranium/latest/themes/material/components/TreeView#lazy-loading

dexterlohnes commented 10 months ago

Hello, @enisn. I am running into similar issues of unresponsiveness when loading only ~650 items. I am using lazy loading but am still running into long UI freezes.

After looking into this some, I believe the issue does not have to do with the loading of my data (which seems to take very little time) but may have to do with instantiation of all the views which are placed in the Tree View. I noticed that the TreeView is in fact a VerticalStackLayout rather than a ListView, and thus it doesn't have any view recycling built in.

Ought the TreeView to be based on a ListView rather than a VerticalStackLayout to avoid hanging when loading many children, even lazily?

enisn commented 10 months ago

It's probably related to dotnet/maui performance. Because UraniumUI just uses simple VerticalStacklayout from Maui with BindableLayout: https://github.com/enisn/UraniumUI/blob/50bd77b0f4c004c4f113bae45214576d85b19c60/src/UraniumUI.Material/Controls/TreeView.cs#L9

When you try loading 1000 items into VerticalStackLayout in Maui, probable you'll get the same lack of performance issue:

<VerticalStackLayout BindableLayout.ItemsSource="{Binding MyHugeList}">
  <BindableLayout.ItemTemplate>
       <DataTemplate>
           <Label Text="{Binding Name}" />
       </DataTemplate>
  <BindableLayout.ItemTemplate>
</VerticalStackLayout>

Yet still, I don't throw the problem to maui team, I'll try to optimize the performance in UraniumUI, but the limit is MAUI performance right now with Native Components.

RalphHachacheCommsoft commented 8 months ago

Is there a way to add a Load More button that loads more children if we have lots of children, if so how would it be done ?

mos379 commented 6 months ago

@enisn Is it possible that this is causing the drama

protected TreeViewNodeItemContentView nodeContainer = new TreeViewNodeItemContentView
    {
        HorizontalOptions = LayoutOptions.Fill,
    };

in the Maui Docu they say: Don't set the HorizontalOptions property of a VerticalStackLayout unless you need to. The default value of LayoutOptions.Fill allows for the best layout optimization. Changing this property has a cost and consumes memory, even when setting it back to its default value.