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

Fixes TextBox measure logic for MaxLines scenario #12589

Merged
merged 2 commits into from
Aug 19, 2023

Conversation

billhenn
Copy link
Contributor

@billhenn billhenn commented Aug 18, 2023

What does the pull request do?

The current TextBox control templates apply the TextBox.Padding (like here) to controls outside of the ScrollViewer. But that leads to margin around the scrollbars, which might not be a desired appearance.
image

This code update walks up the visual tree between TextPresenter and ScrollViewer to look for additional margin/padding that doesn't appear in the Simple or Fluent themes but might in custom control templates. It appends the vertical space so that MaxLines measures correctly in those cases. For instance, the same kind of TextBox with Padding applied within the ScrollViewer would then render like this:
image

What is the current behavior?

Current behavior does not factor in the any Margin or Padding settings that may have been set in a TextBox control template between the ScrollViewer and TextPresenter. This scenario doesn't happen in Simple/Fluent themes but custom themes may run into measure issues.

Without the PR's code update, the second scenario measure incorrectly like:
image

What is the updated/expected behavior with this PR?

The update allows for scrollbars to align right next to the outer border in custom themes, while still having padding within the ScrollViewer as seen above.

How was the solution implemented (if it's not obvious)?

Explained above.

Checklist

Breaking changes

None, the Simple/Fluent themes will still behave the same since there is no Padding set in the scenario that this update looks for.

Obsoletions / Deprecations

None

Fixed issues

None

billhenn and others added 2 commits August 18, 2023 11:15
…tPresenter when calculating MaxLines-based height
…ScrollViewer.MaxHeight based on line height.
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0038562-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@danwalmsley danwalmsley added this pull request to the merge queue Aug 19, 2023
Merged via the queue into AvaloniaUI:master with commit 283c3cd Aug 19, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants