fix(StackPanel): Correct gap spacing when children are collapsed - #3298
Open
bai-chi-xing wants to merge 1 commit into
Open
fix(StackPanel): Correct gap spacing when children are collapsed#3298bai-chi-xing wants to merge 1 commit into
bai-chi-xing wants to merge 1 commit into
Conversation
…hildren - Introduce GetSafeChildAndGapSize method to replace GetSafeChildSize for proper gap handling - Modify measure logic to correctly compute gaps when children are collapsed - Update arrange logic to properly allocate gaps in the presence of collapsed elements - Fix gap handling in scrolling positioning calculations - Add test cases to verify support for collapsed child elements
Author
|
@dotnet-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Details
My English is not very good, so this description was translated with AI — I hope it conveys my intention clearly.
This PR fixes a bug I discovered: when a
StackPanelwith a non-zeroGapis placed inside aScrollViewer, dragging the scrollbar becomes janky and difficult to control.While investigating, I noticed that gap handling was problematic in several places throughout
StackPanel. When collapsed (non-occupying) children were present, gaps were still being included in both measure and arrange calculations — even the finalDesiredSizewas incorrect.To fix this, I consolidated gap sizes into the preceding sibling element of each visible child (regardless of whether that sibling is collapsed or not). This ensures smooth scrolling behavior. However, this changed the meaning of
ScrollPosition, which previously did not account for gaps at all. I've updated the XML documentation comments to clarify the new behavior and warn about potential pitfalls.I've tested the changes locally and confirmed that the scrolling issue is resolved. Since these changes only affect gap handling, I extended the existing tests rather than adding new test files.
This is my first time submitting a PR, so please let me know if I've missed any guidelines or conventions. I'm happy to revise.
Types of changes
Checklist