Fixes TextBox measure logic for MaxLines scenario #12589
Merged
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?
The current
TextBox
control templates apply theTextBox.Padding
(like here) to controls outside of theScrollViewer
. But that leads to margin around the scrollbars, which might not be a desired appearance.This code update walks up the visual tree between
TextPresenter
andScrollViewer
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 thatMaxLines
measures correctly in those cases. For instance, the same kind ofTextBox
withPadding
applied within theScrollViewer
would then render like this:What is the current behavior?
Current behavior does not factor in the any
Margin
orPadding
settings that may have been set in aTextBox
control template between theScrollViewer
andTextPresenter
. 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:
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