# Expander 使用文档
本文档介绍 AtomUI Expander 控件的各种使用方式,示例代码摘自 Gallery 演示程序。
> 📖 Gallery 源码位置:`controlgallery/AtomUIGallery/ShowCases/Views/DataDisplay/ExpanderShowCase.axaml`
---
## 前置准备
```xml
xmlns:atom="https://atomui.net"
xmlns:antdicons="https://atomui.net/icons/antdesign"
```
```csharp
using AtomUI.Desktop.Controls;
```
---
## 1. 基本用法
最简单的用法是创建一个向下展开的面板:
```xml
A dog is a type of domesticated animal. Known for its loyalty and faithfulness,
it can be found as a welcome guest in many households across the world.
```
---
## 2. 三种尺寸
Expander 支持 Large / Middle / Small 三种尺寸,通过 `SizeType` 属性控制:
```xml
A dog is a type of domesticated animal...
A dog is a type of domesticated animal...
A dog is a type of domesticated animal...
```
---
## 3. 展开方向
Expander 支持四个方向的展开(Down / Up / Left / Right),水平方向时头部会自动旋转:
```xml
A dog is a type of domesticated animal...
```
可通过 `OptionButtonGroup` 动态切换展开方向(参见 Gallery 示例)。
---
## 4. 嵌套面板
Expander 可以嵌套在另一个 Expander 内部:
```xml
A dog is a type of domesticated animal...
```
---
## 5. 无边框模式
通过 `IsBorderless` 属性移除外边框,适用于嵌入到有自己边框容器的场景:
```xml
A dog is a type of domesticated animal...
```
---
## 6. 隐藏展开图标
通过 `IsShowExpandIcon` 属性隐藏箭头图标:
```xml
A dog is a type of domesticated animal...
```
---
## 7. 展开图标位置 + 附加内容
通过 `ExpandIconPosition` 切换图标在头部的左侧或右侧。同时可以通过 `AddOnContent` 在头部添加附加内容(如设置图标):
```xml
A dog is a type of domesticated animal...
```
---
## 8. 幽灵模式
通过 `IsGhostStyle` 使头部背景透明:
```xml
A dog is a type of domesticated animal...
```
---
## 9. 触发方式
通过 `TriggerType` 属性控制触发区域。`Header` 模式下点击头部任意位置可展开/收起;`Icon` 模式下仅点击图标可触发:
```xml
A dog is a type of domesticated animal...
A dog is a type of domesticated animal...
A dog is a type of domesticated animal...
```
---
## 10. 自定义间距
通过 `HeaderPadding` 和 `ContentPadding` 属性自定义面板头部和内容区域的内边距:
```xml
A dog is a type of domesticated animal...
A dog is a type of domesticated animal...
```