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

[WinUI] Fix exception when adding items to a linear layout CollectionView #16958

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

emaf
Copy link
Contributor

@emaf emaf commented Aug 23, 2023

Description of Change

When having a CollectionView with a Linear horizontal layout in a Grid with a row definition set to Auto, adding an item would make rezising the inner ItemsWrapGrid enter in an inifinite loop making the height grow indefinetly. The same would happen for for vertical/column/width.

The problem was that when using a linear layout the wrap grid should never have more than one row (it shouldn't wrap the items after exceding its size), regardless of the space available, but the wrap grid was not aware of this. The cycle happened when the wrap grid total height (or width, depending on the orientation) increased, so then we update the item height, but as span is 1 because of linear layout, we ended up setting the total height as item height, forcing the wrap grid to grow again.

The fix is simply configure the ItemsWrapGrid to restrict the number of rows/columns it can have based on what's set for Span.

Issues Fixed

Fixes #16320

Sample provided in the issue after this fix:
image

…View

When having a `CollectionView` with a Linear horizontal layout in a `Grid` with a row definition set to Auto, adding an item would make rezising the inner `ItemsWrapGrid` enter in an inifinite loop making the height grow indefinetly. The same would happen for for vertical/column/width.

The problem was that when using a linear layout the wrap grid should never have more than one row (it shouldn't wrap the items after exceding its size), regardless of the space available, but the wrap grid was not aware of this. The cycle happened when the wrap grid total height (or width, depending on the orientation) increased, so then we update the item height, but as span is 1 because of linear layout, we ended up setting the total height as item height, forcing the wrap grid to grow again.

The fix is simply configure the `ItemsWrapGrid` to restrict the number of rows/columns it can have based on what's set for Span.

Fixes #16320
@emaf emaf requested a review from a team as a code owner August 23, 2023 17:16
@emaf emaf requested review from PureWeen and a team August 23, 2023 17:20
@rmarinho rmarinho merged commit 01fc5eb into main Aug 24, 2023
34 checks passed
@rmarinho rmarinho deleted the dev/ema/cv-crash branch August 24, 2023 12:57
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2023
@samhouts samhouts added the fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[regression/8.0.0-preview.6.8686] [WinUI] CollectionView throws an exception after adding a second item
5 participants