-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix horizontal ScrollBar placement for multi-line TextBox #3934
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
Conversation
Scroll position is now synced correctly, but the visibility property still needs to be respected properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a horizontal scrollbar positioning issue in TextBox controls where the horizontal scrollbar was not properly aligned at the bottom of multiline TextBoxes. The solution implements a custom horizontal scrollbar system that replaces the built-in scrollbar with better positioning control.
Key changes:
- Replaces built-in horizontal scrollbar with custom synchronized scrollbar
- Adds converters for proper scrollbar positioning and width calculation
- Implements behavior for bidirectional synchronization between scrollbars
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| MaterialDesignTheme.TextBox.xaml | Updates TextBox template to use custom horizontal scrollbar with proper Grid layout and synchronization behavior |
| TextBoxHorizontalScrollBarWidthConverter.cs | New converter to calculate custom scrollbar width accounting for vertical scrollbar presence |
| TextBoxHorizontalScrollBarMarginConverter.cs | New converter to calculate custom scrollbar margins considering icons, text, and border states |
| TextBoxHorizontalScrollBarBehavior.cs | New behavior that synchronizes custom scrollbar with built-in hidden scrollbar |
| BoolToTextWrappingConverter.cs | Demo converter for toggling text wrapping in demo application |
| Fields.xaml | Updates demo with checkbox to test text wrapping and horizontal scrollbar functionality |
src/MaterialDesignThemes.Wpf/Converters/Internal/TextBoxHorizontalScrollBarWidthConverter.cs
Show resolved
Hide resolved
src/MaterialDesignThemes.Wpf/Converters/Internal/TextBoxHorizontalScrollBarMarginConverter.cs
Show resolved
Hide resolved
src/MaterialDesignThemes.Wpf/Behaviors/Internal/TextBoxHorizontalScrollBarBehavior.cs
Show resolved
Hide resolved
database64128
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I can confirm that this PR in its current state fixes the bug for my use case, and does not cause any problems for the "Smart Hint" page in the demo app.
corvinsz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I couldn't find anything wrong when testing manually.
Renames `isOutlinedStyle` to `hasOutlinedTextField` in `TextBoxHorizontalScrollBarMarginConverter` for better clarity and consistency.
Adds retry logic to clear button click in date picker test; captures a screenshot of the split button popup during UI test.
|
@nicolaihenriksen after reviewing this and the thread on the other PR with @database64128, I am fine letting this merge. Pushed a small naming cleanup and some UI test fixing. |
Yes this was intentional and yes it will cause an image to always be created. That test is proving to be flaky on several PRs so I am fine with the image so that we can get it working properly. |
Great, PR looks good to me. Will merge it. |
Fixes #3933
Replaces PR #3931
This PR was done in collaboration with @database64128 who initially discovered the issue and created a PR (#3931) with an attempt to fix it.
The straight-forward solution to put the
ScrollBarat the bottom, seems to be just to let thePART_ContentHosthaveVerticalAlignment=Stretch. While this "works", it screws up all sorts of other alignments with leading-/trailing-icons, prefix-/suffix-texts, clear button, etc.So this PR is attempting to solve it differently. Namely by always hiding the built-in horizontal
ScrollBar, and adding in a customScrollBar, which is fixated to the bottom of the control, and syncronized (in both directions) with the built-inScrollBar(which is now always hidden).The syncronization between the
ScrollBarsis done using a behavior, and the correct placement of the customScrollBaris done using a couple of converters taking all the needed parameters into account.I have added the "visual breaking change" although in theory this only affects the multi-line scenario, and only fixes an issue.
EDIT: GitHub Copilots suggested changes were completely crap, but the per-file summary it provided is pretty good actually.