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

SplitButton style #3549

Open
jbooth88 opened this issue Apr 29, 2024 · 4 comments
Open

SplitButton style #3549

jbooth88 opened this issue Apr 29, 2024 · 4 comments
Labels

Comments

@jbooth88
Copy link

Bug explanation

Some button properties in the new materialDesign:SplitButton control are unable to be changed without overriding the ButtonStyle.

For example, altering the font size affects the popup, but the left button (PART_LeftButton) is stuck at 14pt.
I don't know if this is a bug or by design.

Version

5.0

@jbooth88 jbooth88 added bug evaluation required Items is pending review or evaluation by the team labels Apr 29, 2024
@nicolaihenriksen nicolaihenriksen removed the evaluation required Items is pending review or evaluation by the team label Apr 30, 2024
@nicolaihenriksen
Copy link
Contributor

@jbooth88 seems like a bug to me. We should probably forward some additional common, non-inheritable, properties (like FontSize) down to the nested button here.

@Keboo
Copy link
Member

Keboo commented May 9, 2024

So right now the ButtonStyle is what is used to configured the internal buttons. If we do template bindings (which I think might be the right answer), then anything with a template binding can't be set via that style.

I am thinking we might want to just obsolete that property and use template bindings for everything as that is a more common use case. Thoughts?

@nicolaihenriksen
Copy link
Contributor

nicolaihenriksen commented May 9, 2024

@Keboo So the SplitButton.ButtonStyle DP, in my mind, is an implementation detail. It is really only public to allow for consumers to copy-paste-modify the style and still have it compile. The same result could have been achieved without a DP, but simply a well-known resource key (this approach is used for the DatePicker; see here), or an attached property.

The DP serves a single purpose: Mapping an MDIX SplitButton style to the corresponding MDIX Button style. E.g.:
MaterialDesignFlatDarkSplitButton -> MaterialDesignFlatDarkButton,
MaterialDesignOutlinedLightSplitButton -> MaterialDesignOutlinedLightButton,
etc.

Thus the DP is used to make the SplitButton have a correct baseline-look, but should still allow for modifications via its properties as any other control. As such, I think it is fair to simply forward the "common properties" through via TemplateBindings just like it is already doing for a number of the properties. "Common properties" probably covers any property that is intended to have a visual (and/or possibly behavioral) effect that is relevant to the SplitButton.

@jbooth88
Copy link
Author

jbooth88 commented Jun 5, 2024

I think the root cause if this behavior is how the base button styles have setters such as TextBlock.FontSize and TextBlock.FontWeight. Normally having setters like these are not an issue, because users can override style setters easily. However if a style is used for an element inside a control template, the element uses its style setters (when they exist) instead of inheriting from the parent control (I could be wrong here with my limited xaml knowledge, but I think that's how it works?)

So, (focusing on FontSize only for simplicity), possible solutions that I see are:

  1. Set FontSize to {TemplateBinding TextBlock.FontSize} in the PART_LeftButton control, even though we know this will break the ButtonStyle's ability to control the font size. If I understood the previous comments, this is what Nicolai is suggesting?
  2. Add new styles specifically for the SplitButton template, instead of leveraging existing button styles (so much work)
  3. Remove the FontSize setter in base button styles (like MaterialDesignFlatButton). This has an added benefit for users that wish to apply a custom font size to their entire window, for example.
  4. Leave as-is, considering there is a valid work around. In my case, I applied my own ButtonStyle property with setters for the font size and font weights I wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants