Skip to content

Commit fae42f6

Browse files
authored
Defining a FontSize in a FontIcon should not be overridden by its VisualParent's (#1244)
* Defining a FontSize in a FontIcon should not be overridden by its VisualParent's * Only apply the VisualParent override if its size isn't the default we just replaced
1 parent a7d345c commit fae42f6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Wpf.Ui/Controls/IconElement/FontIcon.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ public string Glyph
112112

113113
protected override UIElement InitializeChildren()
114114
{
115-
if (VisualParent is not null)
116-
{
117-
SetCurrentValue(FontSizeProperty, TextElement.GetFontSize(VisualParent));
118-
}
119-
120115
if (FontSize.Equals(SystemFonts.MessageFontSize))
121116
{
122117
SetResourceReference(FontSizeProperty, "DefaultIconFontSize");
118+
119+
// If the FontSize is the default, set it to the parent's FontSize.
120+
if (VisualParent is not null && TextElement.GetFontSize(VisualParent) != SystemFonts.MessageFontSize)
121+
{
122+
SetCurrentValue(FontSizeProperty, TextElement.GetFontSize(VisualParent));
123+
}
123124
}
124125

125126
TextBlock = new TextBlock

0 commit comments

Comments
 (0)