Help us improve
Share bugs, ideas, or general feedback.
From wpf-dev-pack
Designs stand-alone WPF CustomControl styles via ResourceDictionary files merged in Generic.xaml. Use for reusable control libraries and theme organization.
npx claudepluginhub christian289/dotnet-with-claudecode --plugin wpf-dev-packHow this skill is triggered — by the user, by Claude, or both
Slash command
/wpf-dev-pack:designing-wpf-customcontrol-architecturesonnetThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A guide for using CustomControl and ResourceDictionary when writing XAML code in WPF.
Generates WPF CustomControl C# class and XAML ControlTemplate style from a control name. Use when creating a new custom control, scaffolding a templated control, or generating CustomControl boilerplate code.
Designs WinUI 3 UIs and reviews XAML for correctness, covering layout planning, control selection, Fluent Design, theming (Light/Dark/HighContrast), typography, spacing, brushes, accessibility, and data binding.
Building WPF on .NET 8+. Host builder, MVVM Toolkit, Fluent theme, performance, modern C# patterns.
Share bugs, ideas, or general feedback.
A guide for using CustomControl and ResourceDictionary when writing XAML code in WPF.
The templates folder contains a WPF project example (use latest .NET per version mapping).
templates/
├── WpfCustomControlSample.Controls/ ← WPF Custom Control Library
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── Themes/
│ │ ├── Generic.xaml ← MergedDictionaries hub
│ │ └── CustomButton.xaml ← Individual control style
│ ├── CustomButton.cs
│ ├── GlobalUsings.cs
│ └── WpfCustomControlSample.Controls.csproj
└── WpfCustomControlSample.App/ ← WPF Application
├── Views/
│ ├── MainWindow.xaml
│ └── MainWindow.xaml.cs
├── App.xaml
├── App.xaml.cs
├── GlobalUsings.cs
└── WpfCustomControlSample.App.csproj
When generating XAML code, use CustomControl with Stand-Alone Control Style Resource through ResourceDictionary
Purpose: Fix the timing of StaticResource loading and minimize style dependencies
YourProject/
├── Dependencies/
├── Themes/
│ └── Generic.xaml
├── AssemblyInfo.cs
└── CustomControl1.cs
YourProject/
├── Dependencies/
├── Properties/
│ └── AssemblyInfo.cs ← Moved
├── Themes/
│ ├── Generic.xaml ← Use as MergedDictionaries hub
│ ├── CustomButton.xaml ← Individual control style
│ └── CustomTextBox.xaml ← Individual control style
├── CustomButton.cs
└── CustomTextBox.cs
/configuring-wpf-themeinfoGeneric.xaml does not define styles directly; it only performs the role of merging individual ResourceDictionaries:
<!-- Themes/Generic.xaml -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/YourProjectName;component/Themes/CustomButton.xaml" />
<ResourceDictionary Source="/YourProjectName;component/Themes/CustomTextBox.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Define styles in independent XAML files for each control:
<!-- Themes/CustomButton.xaml -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:YourNamespace">
<!-- Control-specific resource definitions -->
<SolidColorBrush x:Key="ButtonBackground" Color="#FF2D5460" />
<SolidColorBrush x:Key="ButtonBackground_MouseOver" Color="#FF1D5460" />
<SolidColorBrush x:Key="ButtonForeground" Color="#FFFFFFFF" />
<!-- Control style definition -->
<Style TargetType="{x:Type local:CustomButton}">
<Setter Property="Background" Value="{StaticResource ButtonBackground}" />
<Setter Property="Foreground" Value="{StaticResource ButtonForeground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background"
Value="{StaticResource ButtonBackground_MouseOver}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
<!-- Themes/Generic.xaml -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/GameDataTool.Controls.Popup;component/Themes/GdtBranchSelectionPopup.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<!-- Themes/GdtBranchSelectionPopup.xaml -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GameDataTool.Controls.Popup"
xmlns:ui="clr-namespace:GameDataTool.Controls.GdtCore.UI;assembly=GameDataTool.Controls.GdtCore"
xmlns:unit="clr-namespace:GameDataTool.Controls.GdtUnits;assembly=GameDataTool.Controls.GdtUnits">
<SolidColorBrush x:Key="ApplyButtonBackground" Color="{DynamicResource Theme_PopupConfirmButtonColor}" />
<SolidColorBrush x:Key="ApplyButtonBackground_MouseOver" Color="#FF1D5460" />
<SolidColorBrush x:Key="ApplyButtonForeground" Color="{DynamicResource Theme_PopupConfirmButtonTextColor}" />
<SolidColorBrush x:Key="CancelButtonBackground" Color="#FFE8EBED" />
<SolidColorBrush x:Key="CancelButtonBackground_MouseOver" Color="#FFC9CDD2" />
<SolidColorBrush x:Key="CancelButtonForeground" Color="#FF323334" />
<Style TargetType="{x:Type local:GdtBranchSelectionPopup}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:GdtBranchSelectionPopup}">
<Border Width="{DynamicResource BranchSelectionPopupWidthSize}"
Height="{DynamicResource BranchSelectionPopupHeightSize}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<!-- Control content -->
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>