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...

@Difegue Difegue requested a review from pomianowski as a code owner October 1, 2024 16:54
@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
@Namax-uniman
Copy link

is this fixed? or are there any way to increase icon size without increasing font size. i am using icon in textbox and the only way to increase the size is by increasing text font size.

@Difegue
Copy link
Contributor Author

Difegue commented Dec 1, 2024

with this PR, you can fully decorrelate icon fontsize from other text.

@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Dec 23, 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 ⭐ top pull request Top pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants