Skip to content

[Windows] Address CollectionView virtualization#18813

Merged
PureWeen merged 3 commits into
mainfrom
foda/CollectionViewVirt
Nov 22, 2023
Merged

[Windows] Address CollectionView virtualization#18813
PureWeen merged 3 commits into
mainfrom
foda/CollectionViewVirt

Conversation

@Foda
Copy link
Copy Markdown
Contributor

@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
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
Copy Markdown
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.

@enkaradag
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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