Bring control into view only if control isn't properly visible in viewport #18359
+46
−21
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.
What does the pull request do?
Brings a control into view when request only if the control is currently not in the scrollviewer's viewport, or such that most of the child is visible in the viewport. Behavior was adapted from WPF's implementation. If the child is completely visible or contains the full viewport, no offset change is done.
What is the current behavior?
Requesting a child be brought into view will always align the top of the child to the top of the viewport, even if the child is fully visible. This forces the scroll offset to change reset even if the child is slightly moved into the viewport manually. This creates problems with focus, as for most focusable controls, they are brought into view on gaining focus. Focus is gained in multiple ways, most common of which is a toplevel activating after being deactivated.
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes #18252