Repository navigation
Smart hint and text box style refactor - #3486
Merged
Merged
Conversation
Keboo
reviewed
Mar 10, 2024
(cherry picked from commit 555d6f9979cb32e004ceb02a716d8fe11ec3d601) (cherry picked from commit 3b61edd)
…e from 0 to desired size
…t in TextBox elements
…rizontally not covered yet
Co-authored-by: Kevin B <Keboo@users.noreply.github.com>
Co-authored-by: Kevin B <Keboo@users.noreply.github.com>
Co-authored-by: Kevin B <Keboo@users.noreply.github.com>
Co-authored-by: Kevin B <Keboo@users.noreply.github.com>
adrbarros
added a commit
to adrbarros/MaterialDesignInXamlToolkit
that referenced
this pull request
Apr 19, 2024
Smart hint and text box style refactor (MaterialDesignInXAML#3486)
This was referenced Sep 26, 2025
This was referenced Jan 24, 2026
This was referenced Feb 9, 2026
This was referenced Mar 21, 2026
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR builds on top of the "RFC" around the
TextBoxstyle change: #3461(Visual) Breaking changes !!!
This PR includes breaking changes.
wpf:HintAssist.IsFloating="True"is no longer enough to change from the default style to the floating hint style. Explicit opt-in in the form ofStyle="{StaticResource MaterialDesignFloatingHintTextBox}"is now required.ControlTemplate.Triggerscollection.TextBoxcontrol height in the various styles are to be expected; this also affects some of the UI tests which have been temporarily modified to run green. When all styles adopt the newSmartHintapproach, they should be able to run "normally" again.General idea
Instead of a
SmartHintconsumer relying on a lot of "magic numbers" to place the floating hint correctly, this PR attempts to let theSmartHinthandle the placement of the floating hint itself, with a few supporting properties.In the layout above, the green box represents the
PART_ContentHostof theTextBoxstyle which holds the user input. The red box represents theSmartHintas a whole; this element spans the width of the prefix-text, the user input, and the suffix-text in the layout to be able to place float the hint to either align with prefix/suffix, or with the user input. The blue/purple box represents the "scaled hint" inside of theSmartHint.From a
SmartHintconsumers point-of-view (e.g. theTextBoxstyle), the idea is that you provide aSmartHint.FloatingTarget, which similarly to thePopup.PlacementTargetis a dependency property where the caller provides a target element which the hint will then (vertically) float on top of. In the example above, theSmartHint.FloatingTargetis set toPART_ContentHostto always float the hint directly on top of the user input. There are a few other supporting properties to enable the hint to horizontally align with either the user input or the prefix/suffix texts; depending on the value ofHorizontalContentAlignmentas well.Examples
In the - slowed down - animations above, you should note that the whole
SmartHint(red box) floats upwards, but only far enough such that the "scaled down hint" (blue/purple box) rests directly on top of theSmartHint.FloatingTarget. Effectively overlapping the user input with the "empty space" left after scaling the hint down. In the outlined style, theSmartHint.FloatingTargetis set as the outerBorder, and a few supporting properties have been set to allow the hint to center align (vertically) with the border line.This approach, in my opinion, works better than the old implementation. The intention is to retain all existing functionality (but improve upon it), and also add support for change of font size and multi-line input. I believe the branch in its current state nearly has that, with just a few minor things I need to look into / clean up.
The intention is to use the
TextBoxstyle as the guinea pig for adopting the new approach, and then to roll it out to all the other styles containing aSmartHintafterwards. Backwards compatibility is intended to be maintained, so if a non-default value forHintAssist.FloatingOffsetis supplied, that will still be respected. It could however be considered a both a behavioral breaking change (alignment with prefix/suffix/user-input) and a (slight) visual breaking change.Funkyness
This particular (existing) feature is rather funky. I retained back-compat of it, but it is not aligned across the styles at all. It seems like a shortcut instead of doing an actual MD3 version of the styles. It basically changes the default
TextBoxstyle so that the underline behaves slightly different on hover.Any comments/feedback/pushback is welcome.