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 GitHubchristian289/dotnet-with-claudecode
wpf-dev-pack
wpf-dev-pack/skills/managing-styles-resourcedictionary/SKILL.md
January 23, 2026
Select agents to install to:
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-resourcedictionaryInstallation paths:
.claude/skills/managing-styles-resourcedictionary/# 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