lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.72k stars 756 forks source link

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

Open Difegue opened 1 month ago

Difegue commented 1 month ago

Pull request type

Please check the type of change your PR introduces:

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