Back to Skills

managing-styles-resourcedictionary

verified

Manages WPF Style definitions and ResourceDictionary patterns including BasedOn inheritance and resource merging. Use when building theme systems, organizing resources, or choosing between StaticResource and DynamicResource.

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/managing-styles-resourcedictionary/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/managing-styles-resourcedictionary/SKILL.md -a claude-code --skill managing-styles-resourcedictionary

Installation paths:

Claude
.claude/skills/managing-styles-resourcedictionary/
Powered by add-skill CLI

Instructions

# WPF Style & ResourceDictionary Patterns

Effectively managing Style and ResourceDictionary for consistent UI and maintainability.

## 1. Style Basic Structure

### 1.1 Explicit Style (With Key)

```xml
<Window.Resources>
    <!-- Explicit style: must reference by key to apply -->
    <Style x:Key="PrimaryButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="#2196F3"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Padding" Value="16,8"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
    </Style>
</Window.Resources>

<Button Style="{StaticResource PrimaryButtonStyle}" Content="Primary"/>
```

### 1.2 Implicit Style (Without Key)

```xml
<Window.Resources>
    <!-- Implicit style: auto-applied to all controls of that type -->
    <Style TargetType="{x:Type Button}">
        <Setter Property="Margin" Value="5"/>
        <Setter Property="Cursor" Value="Hand"/>
    </Style>
</Window.Resources>

<!-- Style automatically applied -->
<Button Content="Auto Styled"/>
```

---

## 2. Style Inheritance (BasedOn)

### 2.1 Basic Inheritance

```xml
<!-- Base button style -->
<Style x:Key="BaseButtonStyle" TargetType="{x:Type Button}">
    <Setter Property="Padding" Value="12,6"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="Cursor" Value="Hand"/>
</Style>

<!-- Primary button: inherits base style -->
<Style x:Key="PrimaryButtonStyle" TargetType="{x:Type Button}"
       BasedOn="{StaticResource BaseButtonStyle}">
    <Setter Property="Background" Value="#2196F3"/>
    <Setter Property="Foreground" Value="White"/>
</Style>

<!-- Secondary button: inherits base style -->
<Style x:Key="SecondaryButtonStyle" TargetType="{x:Type Button}"
       BasedOn="{StaticResource BaseButtonStyle}">
    <Setter Property="Background" Value="#E0E0E0"/>
    <Setter Property="Foreground" Value="#424242"/>
</Style>
```

### 2.2 Implicit Style Inheritance

```xml
<!-- Explicit style inheriting fr

Validation Details

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