Back to Skills

customizing-controltemplate

verified

Customizes WPF control appearance using ControlTemplate with TemplateBinding and ContentPresenter. Use when completely changing control visuals, implementing state-based feedback, or TemplatedParent binding.

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/customizing-controltemplate/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/customizing-controltemplate/SKILL.md -a claude-code --skill customizing-controltemplate

Installation paths:

Claude
.claude/skills/customizing-controltemplate/
Powered by add-skill CLI

Instructions

# WPF ControlTemplate Patterns

All controls inherited from the Control class can completely redefine their visual structure through ControlTemplate.

## 1. Core Concepts

### ControlTemplate vs Style

| Aspect | Style | ControlTemplate |
|--------|-------|-----------------|
| **Role** | Batch property value setting | Visual structure redefinition |
| **Scope** | Property changes only | Full appearance change possible |
| **Target** | All FrameworkElements | Control-derived classes only |

### ControlTemplate Components

- **TargetType**: Control type to which the template applies
- **TemplateBinding**: Connection to TemplatedParent properties
- **ContentPresenter**: Specifies where Content property is rendered
- **Triggers**: State-based visual changes

---

## 2. Basic Implementation Patterns

### 2.1 Button ControlTemplate (XAML)

```xml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="{x:Type Button}" x:Key="RoundedButtonStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <!-- Visual structure definition -->
                    <Border x:Name="PART_Border"
                            CornerRadius="10"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}">

                        <!-- Content rendering location -->
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True"/>
    

Validation Details

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