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

Defining a FontSize in a FontIcon should not be overridden by its VisualParent's #1244

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Difegue
Copy link
Contributor

@Difegue Difegue commented Oct 1, 2024

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

When using a FontIcon, its FontSize will first take the FontSize of its VisualParent if it has one, then be set to DefaultIconFontSize if it's still at the default WPF FontSize.

Both of those actions override whatever FontSize you would set in the FontIcon control itself.
An easy example of this is if I want to have a HyperlinkButton with a custom Icon Font Size:

<ui:HyperlinkButton x:Name="UpgradeHyperlink"
       Margin="0,2,0,0" Height="30"
       Icon="{ui:SymbolIcon ChevronCircleUp20, FontSize=20}"
       Content="Upgrade"
       />

image

Issue Number: N/A

What is the new behavior?

The VisualParent FontSize override now only happens if the FontIcon was using the default WPF FontSize. (as in, no custom sizes were applied)

image

Other information

There's arguably still a problem with this fix if you want a FontIcon whose size coincidentally matches SystemFonts.MessageFontSize within say, a HyperLinkButton with a FontSize of 20. But that'd require deeper architectural changes to handle properly...

@github-actions github-actions bot added controls Changes to the appearance or logic of custom controls. PR Pull request icons Fonts and icons updates dotnet release labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls Changes to the appearance or logic of custom controls. dotnet icons Fonts and icons updates PR Pull request release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant