# ListBox 自定义样式指南
ListBox 控件族的视觉表现通过 `ControlTheme` + Design Token 系统控制。以下介绍各种常见的自定义方式。
---
## 1. 使用属性直接控制
### 尺寸
```xml
```
### 无边框模式
```xml
```
### 自定义悬浮和选中背景色
```xml
```
### 选中指示器
```xml
```
### 禁用选择
```xml
```
### 过滤与高亮
```xml
```
### 自定义空状态
```xml
```
---
## 2. 通过 Style 覆盖样式
### 全局 ListBox 样式
```xml
```
### 自定义 ListBoxItem 样式
```xml
```
### 按尺寸定制
```xml
```
---
## 3. 通过 ControlTheme 完全替换主题
如需彻底替换 ListBox 或 ListBoxItem 的模板:
```xml
```
> ⚠️ 注意:完全替换 ControlTheme 将丢失内置的选中指示器和过滤高亮功能。建议优先使用 Style 覆盖。
---
## 4. 自定义 ItemTemplate
通过 `ItemTemplate` 自定义列表项的内容布局:
```xml
```
---
## 样式选择器速查
### ListBox 选择器
| 选择器 | 说明 |
|---|---|
| `atom\|ListBox` | 匹配所有 ListBox 实例 |
| `atom\|ListBox[SizeType=Large]` | 匹配大号 ListBox |
| `atom\|ListBox[SizeType=Middle]` | 匹配中号 ListBox |
| `atom\|ListBox[SizeType=Small]` | 匹配小号 ListBox |
| `atom\|ListBox[IsBorderless=True]` | 匹配无边框 ListBox |
### ListBoxItem 选择器
| 选择器 | 说明 |
|---|---|
| `atom\|ListBoxItem` | 匹配所有 ListBoxItem |
| `atom\|ListBoxItem:selected` | 匹配选中状态的 ListBoxItem |
| `atom\|ListBoxItem:pointerover` | 匹配鼠标悬浮的 ListBoxItem |
| `atom\|ListBoxItem:disabled` | 匹配禁用的 ListBoxItem |
| `atom\|ListBoxItem:selected:not(:disabled)` | 匹配非禁用的选中项 |
### 模板内部元素选择器
| 选择器 | 说明 |
|---|---|
| `atom\|ListBoxItem /template/ Border#Frame` | 列表项外框 |
| `atom\|ListBoxItem /template/ ContentPresenter#ContentPresenter` | 列表项内容区 |
| `atom\|ListBoxItem /template/ atom\|IconPresenter#SelectedIndicator` | 选中指示器图标 |
| `atom\|ListBox /template/ ContentPresenter#EmptyIndicator` | 空状态指示器 |