Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Address CollectionView virtualization #18813

Merged
merged 3 commits into from
Nov 22, 2023
Merged

Conversation

Foda
Copy link
Member

@Foda Foda commented Nov 16, 2023

Description of Change

This PR some-what addresses virtualization being broken in CollectionView due to a lack of MinHeight on the items, the initial MeasureOverride call returning an infinite height, and creating the ListView items at the DataBinding-time.

You can see the behavior in an isolated WinUI context here: https://github.com/Foda/ListViewVirtualization/tree/master

The fix for this issue is to just return a real-number value (32) when the initial call to MeasureOverride is done. It's not perfect, but very large lists will benefit from it.

Note: this behavior was regressed due to #18356

Issues Fixed

Fixes #18639 #18510

@Foda Foda added platform/windows 🪟 area-controls-collectionview CollectionView, CarouselView, IndicatorView i/regression This issue described a confirmed regression on a currently supported version labels Nov 16, 2023
@Foda Foda requested a review from a team as a code owner November 16, 2023 19:24
@@ -284,6 +284,10 @@ protected override WSize MeasureOverride(WSize availableSize)
{
if (_renderer == null)
{
// Make sure we supply a real number for height otherwise virtualization won't function
if (double.IsFinite(availableSize.Width) && !double.IsFinite(availableSize.Height))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to make sure this is ok in CV scenarios where we have horizontal list scrolling set as the layout.

@PureWeen PureWeen merged commit 926a002 into main Nov 22, 2023
47 checks passed
@PureWeen PureWeen deleted the foda/CollectionViewVirt branch November 22, 2023 22:20
@enkaradag
Copy link

Hi,

I couldn't figure out where i shall use MeasureOverride to prevent CollectionView load all data at databinding

Here is my simple code

CollectionView view = new CollectionView() {HeightRequest=500};

///create 1000 rows of data here as ObservableCollection<MyDataClass> RowList

view.ItemTemplate = new DataTemplate(()=>
{
                Grid g = new Grid();
                Label lbl = new Label();
                lbl.SetBinding(Label.TextProperty, "FieldOfMyDataClass");
                g.Children.Add(lbl);
                return g;
}

view.ItemsSource=RowList

@enkaradag
Copy link

Hi,

i tried both MesureOverride of CollectionView and Grid. MeasureOverride of Grid is never calling, CollectionView's MeasureOverride is called with infinity value. Set it to an integer. But noway, it still attempts to loads all rows at databinding.

This issue is marked as fixed and closed. But i couldn't make it work for maui windows. Any help on this?

Or (I don't know the terminology) is this fix planned to be published later with SR1 or SR2?

My older post #18913

Best Regards

@Elangovan4ever
Copy link

I also have the same issue in Window. Using 2000 items in collection view just with one label makes the app stuck and not respond. Using .NET 8 LTS. Please. If there is a workaround for time being, please let us know.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2024
@samhouts samhouts added the fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[regression/8.0.0-rc.2.9530] Completely broken virtualization in CollectionView
7 participants