wpf-rule-resourcedictionary-patterns — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited wpf-rule-resourcedictionary-patterns (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Rules for organizing ResourceDictionary files in WPF custom control libraries.
Generic.xaml must function exclusively as a hub that merges other dictionaries. Never define inline styles, templates, or resources directly in Generic.xaml.
<!-- Correct: Generic.xaml is only a hub -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Colors.xaml" />
<ResourceDictionary Source="/Themes/MyButton.xaml" />
<ResourceDictionary Source="/Themes/MyTextBox.xaml" />
<ResourceDictionary Source="/Themes/MySlider.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary><!-- Prohibited: inline style in Generic.xaml -->
<ResourceDictionary ...>
<Style TargetType="{x:Type local:MyButton}">
...
</Style>
</ResourceDictionary>Every custom control gets its own XAML file under Themes/:
MyControlLibrary/
├── Themes/
│ ├── Generic.xaml ← hub only, no styles
│ ├── Colors.xaml ← shared color/brush resources
│ ├── MyButton.xaml ← ControlTemplate for MyButton
│ ├── MyTextBox.xaml ← ControlTemplate for MyTextBox
│ └── MySlider.xaml ← ControlTemplate for MySlider
├── MyButton.cs
├── MyTextBox.cs
└── MySlider.csWithin any single XAML file, define resources in this order:
x:Key named resources (colors, brushes, geometry, converters)Style definitions (which reference the above by StaticResource)<ResourceDictionary ...>
<!-- 1. Named resources first -->
<Color x:Key="PrimaryColor">#FF2196F3</Color>
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource PrimaryColor}" />
<!-- 2. Styles second -->
<Style TargetType="{x:Type local:MyButton}">
<Setter Property="Background" Value="{StaticResource PrimaryBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyButton}">
...
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>| Scenario | Use |
|---|---|
| Resource defined in same file or merged earlier | StaticResource |
| Resource may change at runtime (theme switching) | DynamicResource |
| Resource defined in a later-merged dictionary | DynamicResource |
| ControlTemplate internal references | TemplateBinding (not resource lookup) |
Prefer StaticResource by default — it is resolved at load time and has zero runtime overhead. Use DynamicResource only when runtime replacement is explicitly required.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.