-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Windows] - Fix Grid layout not updating when Row/Column changed dynamically #30206
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
base: main
Are you sure you want to change the base?
Conversation
Hey there @@prakashKannanSf3972! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that dynamic changes to Grid.Row
and Grid.Column
on Windows correctly invalidate the parent layout so the UI updates without requiring a window resize.
- Added a UI sample page in the HostApp for toggling row/column at runtime.
- Added a cross-platform UI test in TestCases.Shared.Tests to verify dynamic grid updates.
- Updated
Grid.cs
to propagate measure invalidation to the parent grid on Windows.
Reviewed Changes
Copilot reviewed 3 out of 11 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20404.cs | New UITest verifying dynamic row/column toggles trigger layout updates. |
src/Controls/tests/TestCases.HostApp/Issues/Issue20404.cs | New sample page with buttons to toggle grid row/column dynamically. |
src/Controls/src/Core/Layout/Grid.cs | Updated Invalidate method to explicitly invalidate parent grid on Windows. |
if (grid.Parent is Grid containerGrid) | ||
{ | ||
containerGrid.InvalidateMeasure(); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning immediately after invalidating the parent skips the grid's own InvalidateMeasure
call. To guarantee both the grid and its container are re‐measured, consider calling grid.InvalidateMeasure()
before or after invalidating the parent instead of exiting early.
return; | |
grid.InvalidateMeasure(); |
Copilot uses AI. Check for mistakes.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
Grid.Row
orGrid.Column
properties are updated on aGrid
element nested within anotherGrid
, the current implementation only invalidates the element itself and does not propagate the invalidation to its parent. As a result, the parent layout is not re-measured or arranged correctly, leading to inaccurate or incomplete rendering.Description of Change
Grid
on Windows to ensure UI updates correctly whenGrid.Row
orGrid.Column
properties change.Issues Fixed
Fixes #20404
Tested the behaviour in the following platforms
Output
BeforeFix_Grid.mp4
AfterFix_Grid.mp4