Back to Skills

resolving-icon-font-inheritance

verified

Resolves text font inheritance issues when using Segoe Fluent Icons in WPF CustomControl. Use when TextBlocks inherit icon fonts unexpectedly within ControlTemplate.

View on GitHub

Marketplace

dotnet-claude-plugins

christian289/dotnet-with-claudecode

Plugin

wpf-dev-pack

development

Repository

christian289/dotnet-with-claudecode
5stars

wpf-dev-pack/skills/resolving-icon-font-inheritance/SKILL.md

Last Verified

January 23, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/christian289/dotnet-with-claudecode/blob/main/wpf-dev-pack/skills/resolving-icon-font-inheritance/SKILL.md -a claude-code --skill resolving-icon-font-inheritance

Installation paths:

Claude
.claude/skills/resolving-icon-font-inheritance/
Powered by add-skill CLI

Instructions

# 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

```xml
<!-- 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

1. **Apply icon font only to specific element**: Specify

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
2485 chars