understanding-wpf-content-model
Explains WPF content model hierarchy including ContentControl, ItemsControl, and Headered variants. Use when selecting base classes for custom controls or understanding content/items properties.
What this skill does
# WPF Content Model Patterns
WPF controls are classified into 4 main models based on how they contain content.
## 1. Content Model Hierarchy
```
Control
├── ContentControl (Single Content)
│ ├── Button
│ ├── Label
│ ├── CheckBox
│ ├── RadioButton
│ ├── ToolTip
│ ├── ScrollViewer
│ ├── UserControl
│ ├── Window
│ └── HeaderedContentControl (Content + Header)
│ ├── Expander
│ ├── GroupBox
│ └── TabItem
│
└── ItemsControl (Multiple Items)
├── ListBox
├── ComboBox
├── ListView
├── TreeView
├── Menu
├── TabControl
└── HeaderedItemsControl (Items + Header)
├── MenuItem
├── TreeViewItem
└── ToolBar
```
---
## 2. ContentControl
### 2.1 Characteristics
- **Single Content property**: Holds only one child element
- **Content type**: object (allows all types)
- **ContentTemplate**: Specifies how Content is rendered
### 2.2 Basic Usage
```xml
<!-- String content -->
<Button Content="Click Me"/>
<!-- Complex content -->
<Button>
<StackPanel Orientation="Horizontal">
<Image Source="/icon.png" Width="16"/>
<TextBlock Text="Save" Margin="5,0,0,0"/>
</StackPanel>
</Button>
```
### 2.3 Using ContentTemplate
```xml
<Button Content="Download">
<Button.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Path Data="M12,2L12,14L8,10L12,14L16,10L12,14"
Fill="White" Width="16"/>
<TextBlock Text="{Binding}" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>
</Button.ContentTemplate>
</Button>
```
> **Advanced**: See [ADVANCED.md](ADVANCED.md) for creating custom ContentControl, ItemsControl, HeaderedContentControl-derived controls, custom ItemsPanel, and HierarchicalDataTemplate.
---
## 3. ItemsControl
### 3.1 Characteristics
- **Items collection**: Holds multiple child elements
- **ItemsSource**: Source for data binding
- **ItemTemplate**: Rendering method for each item
- **ItemsPanel**: Specifies the panel for item layout
### 3.2 Basic Usage
```xml
<!-- Direct item addition -->
<ListBox>
<ListBoxItem Content="Item 1"/>
<ListBoxItem Content="Item 2"/>
<ListBoxItem Content="Item 3"/>
</ListBox>
<!-- Data binding -->
<ListBox ItemsSource="{Binding Products}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
<TextBlock Text="{Binding Price, StringFormat=${0:N2}}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
```
---
## 4. HeaderedContentControl
### 4.1 Characteristics
- **Header + Content**: Two separate regions
- **HeaderTemplate**: Header rendering method
- **ContentTemplate**: Content rendering method
### 4.2 Representative Controls
```xml
<!-- GroupBox -->
<GroupBox Header="Settings">
<StackPanel>
<CheckBox Content="Option 1"/>
<CheckBox Content="Option 2"/>
</StackPanel>
</GroupBox>
<!-- Expander -->
<Expander Header="Details" IsExpanded="False">
<TextBlock Text="Content not visible when collapsed"/>
</Expander>
<!-- TabItem -->
<TabControl>
<TabItem Header="Tab 1">
<TextBlock Text="Tab 1 content"/>
</TabItem>
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<Ellipse Width="8" Height="8" Fill="Green"/>
<TextBlock Text="Status" Margin="5,0,0,0"/>
</StackPanel>
</TabItem.Header>
<TextBlock Text="Tab 2 content"/>
</TabItem>
</TabControl>
```
---
## 5. HeaderedItemsControl
### 5.1 Characteristics
- **Header + Items**: Header and multiple items
- Suitable for representing **hierarchical structures**
### 5.2 Representative Controls
```xml
<!-- TreeViewItem -->
<TreeView>
<TreeViewItem Header="Folder 1">
<TreeViewItem Header="File 1.txt"/>
<TreeViewItem Header="File 2.txt"/>
<TreeViewItem Header="Subfolder">
<TreeViewItem Header="File 3.txt"/>
</TreeViewItem>
</TreeViewItem>
</TreeView>
<!-- MenuItem -->
<Menu>
<MenuItem Header="File">
<MenuItem Header="New"/>
<MenuItem Header="Open"/>
<Separator/>
<MenuItem Header="Recent Files">
<MenuItem Header="file1.txt"/>
<MenuItem Header="file2.txt"/>
</MenuItem>
</MenuItem>
</Menu>
```
---
## 6. Control Selection Guide
| Scenario | Recommended Base Class |
|----------|------------------------|
| Display single content | ContentControl |
| Single content + title | HeaderedContentControl |
| Display list/collection | ItemsControl |
| Selectable list | Selector (ListBox, ComboBox) |
| Hierarchical data | HeaderedItemsControl |
| Input field | TextBoxBase |
| Range value selection | RangeBase |
---
## 7. Content Property Processing Flow
```
Content Set
↓
ContentTemplate exists?
├── Yes → Render with DataTemplate
└── No → Check Content type
├── UIElement → Render directly
├── String → Render with TextBlock
└── Other → ToString() then TextBlock
```
---
## 8. References
- [WPF Content Model - Microsoft Docs](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/wpf-content-model)
- [ItemsControl Class - Microsoft Docs](https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.itemscontrol)
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.