← Back to list

resolving-icon-font-inheritance
by christian289
ClaudeCode와 함께하는 .NET 개발 튜토리얼
⭐ 1🍴 0📅 Jan 25, 2026
SKILL.md
name: resolving-icon-font-inheritance description: "Resolves text font inheritance issues when using Segoe Fluent Icons in WPF CustomControl. Use when TextBlocks inherit icon fonts unexpectedly within ControlTemplate."
WPF CustomControl Icon Font Inheritance Issue Resolution
Problem Scenario
When using Segoe Fluent Icons font in WPF CustomControl, TextBlocks within the same ControlTemplate inherit the icon font, causing text to render incorrectly.
Symptoms
- Button text displays as square boxes (□) or strange symbols
- Icons display correctly but regular text doesn't render
Cause
WPF's FontFamily is inherited to child elements following the Visual Tree. When FontFamily="Segoe Fluent Icons" is set on a TextBlock for icons within a ControlTemplate, other TextBlocks in the same container may inherit this font.
Solution
Explicitly Specify FontFamily on Text-Displaying Elements
<!-- IconButton ControlTemplate Example -->
<ControlTemplate TargetType="{x:Type local:IconButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Orientation="{TemplateBinding Orientation}"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<!-- Icon: Use Segoe Fluent Icons -->
<TextBlock x:Name="PART_Icon"
Text="{TemplateBinding Icon}"
FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets"
FontSize="{TemplateBinding IconSize}"
Foreground="{TemplateBinding Foreground}" />
<!-- Text: Explicitly specify Segoe UI (Important!) -->
<TextBlock x:Name="PART_Text"
Text="{TemplateBinding Text}"
FontFamily="Segoe UI"
FontSize="12"
Foreground="{TemplateBinding Foreground}"
VerticalAlignment="Center" />
</StackPanel>
</Border>
</ControlTemplate>
Key Points
- Apply icon font only to specific element: Specify
Segoe Fluent Iconsonly onPART_Icon - Explicitly specify FontFamily on text elements:
FontFamily="Segoe UI"is required onPART_Text - Don't set FontFamily on parent containers: Setting FontFamily on Border or StackPanel inherits to all children
Applicable Controls
- IconButton (icon + text button)
- IconToggleButton (toggleable icon button)
- NavigationButton (navigation menu item)
- Any other CustomControl using icons and text together
Related Icon Fonts
| Font Name | Windows Version | Purpose |
|---|---|---|
Segoe Fluent Icons | Windows 11+ | Latest Fluent Design icons |
Segoe MDL2 Assets | Windows 10+ | Default system icons |
Fallback Pattern
FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets"
Specify fallback font for Windows 10 compatibility
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon
