Configures ThemeInfo attribute in AssemblyInfo.cs for WPF CustomControl Generic.xaml auto-loading. Use when creating WPF Custom Control Library projects or troubleshooting missing control styles.
View on GitHubchristian289/dotnet-with-claudecode
wpf-dev-pack
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/christian289/dotnet-with-claudecode/blob/main/wpf-dev-pack/skills/configuring-wpf-themeinfo/SKILL.md -a claude-code --skill configuring-wpf-themeinfoInstallation paths:
.claude/skills/configuring-wpf-themeinfo/# WPF ThemeInfo Configuration
Configuring the `ThemeInfo` attribute for automatic Generic.xaml loading in WPF Custom Control Library projects.
## Overview
WPF uses the `ThemeInfo` attribute to locate theme-specific and generic resource dictionaries at runtime. Without this attribute, `Themes/Generic.xaml` will **not** be loaded automatically, and CustomControl styles will not be applied.
---
## 1. AssemblyInfo.cs Configuration
### Required Code
```csharp
// Properties/AssemblyInfo.cs
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, // Theme-specific resources
ResourceDictionaryLocation.SourceAssembly)] // Generic resources (Themes/Generic.xaml)
```
### File Location
```
YourProject/
├── Properties/
│ └── AssemblyInfo.cs ← ThemeInfo attribute here
├── Themes/
│ └── Generic.xaml ← Auto-loaded by ThemeInfo
└── CustomButton.cs
```
---
## 2. ResourceDictionaryLocation Options
| Value | Description | Use Case |
|-------|-------------|----------|
| `None` | No resource dictionary for this category | Theme-specific: when no OS theme customization needed |
| `SourceAssembly` | Resources in the current assembly | Generic: load from `Themes/Generic.xaml` in this assembly |
| `ExternalAssembly` | Resources in a separate assembly | When themes are packaged in `YourAssembly.ThemeName.dll` |
### Parameter Meanings
```csharp
[assembly: ThemeInfo(
themeDictionaryLocation, // 1st: Theme-specific (e.g., Aero, Luna)
genericDictionaryLocation)] // 2nd: Generic fallback (Themes/Generic.xaml)
```
- **1st parameter** (`themeDictionaryLocation`): OS theme-specific styles (rarely used)
- **2nd parameter** (`genericDictionaryLocation`): Generic.xaml location (**must be `SourceAssembly`**)
---
## 3. Anti-Pattern: App.xaml MergedDictionaries
### Bad Example
```xml
<!-- App.xaml - DO NOT DO THIS for CustomControl styles -->
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.Merge