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

Bring control into view only if control isn't properly visible in viewport #18359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emmauss
Copy link
Contributor

@emmauss emmauss commented Mar 3, 2025

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

@emmauss emmauss changed the title Bring control into view only if control isn't currently in viewport Bring control into view only if control isn't properly visible in viewport Mar 3, 2025
@emmauss emmauss requested review from MrJul and grokys March 3, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScrollViewer with SelectableTextBlock scrolls up when focus changes
2 participants