---
name: wpf-xaml-style-generator
description: Generate XAML styles, templates, and resource dictionaries with theme support for WPF applications
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
tags: [wpf, xaml, styles, themes, ui]
---
# wpf-xaml-style-generator
Generate XAML styles, control templates, and resource dictionaries with theme support for WPF applications. This skill creates consistent, maintainable UI styling following modern design principles.
## Capabilities
- Generate control styles and templates
- Create resource dictionaries with theme support
- Set up light/dark theme switching
- Generate brush and color resources
- Create custom control templates
- Set up implicit vs explicit styles
- Generate animation resources
- Configure Fluent Design integration
## Input Schema
```json
{
"type": "object",
"properties": {
"projectPath": {
"type": "string",
"description": "Path to the WPF project"
},
"designSystem": {
"enum": ["fluent", "material", "custom"],
"default": "fluent"
},
"themes": {
"type": "array",
"items": { "enum": ["light", "dark", "high-contrast"] },
"default": ["light", "dark"]
},
"controls": {
"type": "array",
"items": {
"enum": ["button", "textbox", "combobox", "listbox", "datagrid", "menu", "all"]
},
"default": ["all"]
},
"accentColors": {
"type": "object",
"properties": {
"primary": { "type": "string" },
"secondary": { "type": "string" }
}
},
"includeAnimations": {
"type": "boolean",
"default": true
}
},
"required": ["projectPath"]
}
```
## Output Schema
```json
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"type": { "enum": ["colors", "brushes", "styles", "templates", "themes"] }
}
}
},
"mergedDictionaries": { "type": "array", "items": { "type": "string" } }
},
"required": ["success"]
}
```
## Resource Dictionary Structure
```
Resources/
├── Themes/
│ ├── Colors.Light.xaml
│ ├── Colors.Dark.xaml
│ └── Colors.HighContrast.xaml
├── Brushes.xaml
├── Styles/
│ ├── ButtonStyles.xaml
│ ├── TextBoxStyles.xaml
│ ├── ComboBoxStyles.xaml
│ └── DataGridStyles.xaml
├── Templates/
│ └── ControlTemplates.xaml
└── Themes.xaml (merged dictionary)
```
## Generated XAML Examples
### Colors.Light.xaml
```xml
#FFFFFF
#F3F3F3
#E5E5E5
#1A1A1A
#666666
#ABABAB
#0078D4
#005A9E
#4BA0E8
#D6D6D6
#0078D4
#8A8A8A
#107C10
#FF8C00
#D13438
#0078D4
```
### Brushes.xaml
```xml
```
### ButtonStyles.xaml
```xml
```
### Theme Manager
```csharp
public class ThemeManager
{
private const string ThemesPath = "pack://application:,,,/Resources/Themes/";
public static void SetTheme(string themeName)
{
var app = Application.Current;
var dictionaries = app.Resources.MergedDictionaries;
// Remove existing theme
var existingTheme = dictionaries.FirstOrDefault(d =>
d.Source?.OriginalString.Contains("Colors.") ?? false);
if (existingTheme != null)
{
dictionaries.Remove(existingTheme);
}
// Add new theme
var themeUri = new Uri($"{ThemesPath}Colors.{themeName}.xaml");
dictionaries.Insert(0, new ResourceDictionary { Source = themeUri });
}
public static string CurrentTheme { get; private set; } = "Light";
public static void ToggleTheme()
{
CurrentTheme = CurrentTheme == "Light" ? "Dark" : "Light";
SetTheme(CurrentTheme);
}
}
```
### App.xaml
```xml
```
## Best Practices
1. **Use DynamicResource**: For theme-switchable resources
2. **Organize by function**: Colors, brushes, styles separately
3. **Follow naming conventions**: Consistent resource key names
4. **Provide base styles**: Allow easy customization
5. **Test all themes**: Verify contrast and accessibility
6. **Document resources**: Comment complex templates
## Related Skills
- `wpf-mvvm-scaffold` - Application architecture
- `wpf-high-dpi-analyzer` - DPI scaling
- `desktop-ui-implementation` process - UI workflow
## Related Agents
- `wpf-dotnet-expert` - WPF expertise
- `platform-convention-advisor` - Design guidelines