# TextBlock 使用文档
本文档介绍 AtomUI TextBlock 控件的各种使用方式。
---
## 前置准备
在 AXAML 中使用 TextBlock,需要引入以下命名空间:
```xml
xmlns:atom="https://atomui.net"
```
在 C# 代码中引入:
```csharp
using AtomUI.Desktop.Controls; // TextBlock 控件
```
---
## 1. 基本文本显示
最基本的用法,显示一段文本:
```xml
Hello, AtomUI!
```
---
## 2. 文本换行
通过 `TextWrapping` 属性控制换行行为:
```xml
```
---
## 3. 省略号裁剪
当文本超出可用空间时,显示省略号(`…`):
```xml
```
---
## 4. 多行限制
通过 `MaxLines` 限制最大显示行数,超出部分裁剪:
```xml
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore.
```
---
## 5. 文本装饰
通过 `TextDecorations` 添加下划线、删除线等装饰:
```xml
```
---
## 6. 富文本(Inlines)
通过 `Inlines` 实现段内混合格式文本:
```xml
```
---
## 7. 使用 Token 保持主题一致性
在 AtomUI 中推荐通过 `SharedTokenResource` 引用全局 Token,而非硬编码颜色和字号:
```xml
```
---
## 8. 在 Form 中使用
TextBlock 实现了 `IFormItemAware` 接口,可作为只读展示字段参与 Form 表单:
```xml
```
---
## 9. 数据绑定
TextBlock 的 `Text` 属性支持标准 Avalonia 数据绑定:
```xml
```
---
## 常见组合模式
### 标题 + 描述
```xml
```
### 操作链接分隔
```xml
Edit
Delete
```
### 状态文本
```xml
```