-
Notifications
You must be signed in to change notification settings - Fork 3.5k
TextBox: Respect externally set TextBox.Padding in triggers #3074
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
@Keboo I converted it back to a draft because, although it solves the problem, I am not really happy with the solution. Reason being that it violates the "principle of least astonishment". The problem is that the triggers override the padding for the filled/outlined styles effectively ignoring any value set by the user. We could add attached properties for these paddings allowing the user to control the padding for these styles, but then it is still sort of strange that Do you have a good idea on how to make the |
That is a good question. I do agree that combining two Thickness values together is not expected behavior. I am wondering with the 5.0.0 release if it might be worth getting rid of the attached properties and instead split the templates. Though I realize this is significantly more work. |
c60ad9c
to
bb64eaf
Compare
After a good nights sleep, it finally dawned on me what I was doing wrong. I believe what needs to happen is that any "template-level" property (e.g. Whether we should split the templates is a good question. It would be a lot to maintain if nothing can be shared. Sharing between control templates is, to my knowledge, only really possible if you extract the shared XAML into an (internal) custom control for which we then define a template and expose whatever properties we need to be able to mutate. Personally I think we should try hard to stick with one template, and then perhaps not rely as much on the triggers (on attached properties) but rather explicitly override values in the style overrides. Thoughts? |
@Keboo See my comment above. Do you see this as a reasonable approach? If not, I won't bother implementing it for the remaining templates. |
Hi @nicolaihenriksen sorry, I lost track of the notification on this one. YES! I completely overlooked that style of solution. You are absolutely correct, that if we use control template triggers they will make it quite difficult for people to override the values. I think this is an excellent solution. |
Also extended the SmartHint demo to be able to toggle the HintAssit.IsFloating on/off.
bb64eaf
to
4b3dff7
Compare
@Keboo I applied the same changes for the The Also, for the |
@Keboo Also, there are some alignment issues with respect to the helper text. I think I may open up a "cleanup" PR to fix the padding issue for |
That would be awesome. Thank you! |
FINAL UPDATE I think I may have dug deep enough to see what is happening. It seems the intention of the @Keboo I think I may be missing some MDIX historical knowledge here, perhaps you can help me out. It is not entirely clear to me what the purpose of UPDATE Also, it kind of conflicts with The values currently being used for the attached property are contributing to some of the slight misalignments of the hint and helper text that we're currently seeing. It is not a whole lot so I could do the PR without touching this AP, but I just worry that everything falls apart if a user sets a custom value for the AP because it is not respected/applied consistently. In the GIF below you can see that the validation error does not respect the |
I am going to spend some time on my stream tonight going through this. I agree this is quite complicated. I am not sure of the right answer, and I think I need to spend some time playing with the changes in your pull request. |
The changes currently in there only fix the overall scheme: hint and helper text should also follow padding (at least it seems so when looking at material.io). I believe I know how to fix the remaining "minor misalignments" but don't have time to finish it before your stream. Looking forward to see your stream. |
Awesome. I will probably still spend some time playing with it just to make sure I understand everything. Really great work as always! |
If you could look into whether you agree with ny assesment that TextFieldAssist.TextBoxViewMargin should only be used to manipulate PART_ContentHost (and similar) and NOT hints, helpers or validation, that would be awesome. Thats is at least what I think is the right approach. The remaining part is then about ensuring left edge of all those elements align nicely. Another topic is the placement of helper and validation when HorizontalContentAlignment is Center or Right... |
Yes, I believe only using
I think those can be separate PRs, but I think they should follow the HorizontalContentAlignment. We should also consider FlowDirection. |
Perfect, I will remove the "wrong usages" of it then.
Agree. I will create separate PRs for that and will also consider FlowDirection. Hopefully these templates (or at least the areas regarding hint/helper) are simple enough that "it just works", but I will be sure to test it. On your stream you were debating whether an AP should be created to provide extra control over the placement of the hint/helper/validation. I agree this is a good idea; in fact I already added that for the hint in a previous PR - although that AP only affects the positioning when the hint floats. The AP is basically an Another minor thing. The demo app has both the |
Fixes #3058
Fixes #3076
This PR extracts the
TextBox.Padding
setters out of the trigger collection and into the overridenStyle
instead. This allows the user to override them.There is a consequence to this however: you now have to set the style, you cannot only set the attached properties. This is a visual breaking change. You can see how I needed to modify the
MainWindow.xaml
to get the correct behavior for theDemoItemsSearchBox
.There is also another (internal) consequence, which is that any trigger or similar which previously relied on the "hardcoded" padding for a particular style, now needs to respect any margin because the user can override it.
There is also the fact that this is not limited to the
TextBox
styles. If we decide to go this route, it should be fixed for all filled/outlined styles in a similar manner.In the example below, I have set

TextBox.Padding="5"
on theSmartHint
demo page (via a style setter) to illustrate that it is now possible to override in a style.