understanding-wpf-content-modellisted
Install: claude install-skill christian289/dotnet-with-claudecode
# 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"/