CollectionView item spacing/layout breaks when item visibility changes dynamically #34995
Unanswered
pallav1111
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
CollectionView doesn't recalculate layout on |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I’m running into inconsistent layout behavior in a MAUI page that uses a
CollectionViewinside a vertically stacked layout, where item visibility changes dynamically.The UI is structured with:
CollectionViewCollectionViewcan toggleIsVisibleat runtimeProblem
When switching between sections or when individual items toggle visibility:
This leads to a visually broken layout, especially when multiple items toggle visibility dynamically.
Expected Behavior
IsVisibleis set tofalse, it should not occupy spaceItemSpacinginLinearItemsLayout) should be recalculated correctlyActual Behavior
Simplified XAML Structure
Each item inside
Itemshas:IsVisible="{Binding IsVisible}"Notes / Observations
Issue appears when:
IsVisibleon items dynamicallyRemoving hidden items from the collection entirely fixes the issue (but is not always feasible)
Forcing layout updates manually does not consistently resolve the problem
Questions
Is
CollectionViewexpected to fully re-measure layout whenIsVisiblechanges on item templates?Is this a known limitation or bug with virtualization or layout invalidation?
What is the recommended approach for dynamic visibility:
IsVisibleIs there a reliable way to force layout recalculation for
CollectionViewitems?Environment
Beta Was this translation helpful? Give feedback.
All reactions