---
name: creating-wpf-flowdocument
description: Creates WPF FlowDocument for rich text display with Paragraph, Table, List elements. Use when building document viewers, rich text editors, or printable reports.
---
# WPF FlowDocument Patterns
Creating rich, paginated documents with flowing text content.
**Advanced Patterns:** See [ADVANCED.md](ADVANCED.md) for programmatic creation, printing, and file I/O.
## 1. FlowDocument Overview
```
FlowDocument
├── Block Elements (Paragraph, Section, List, Table, BlockUIContainer)
│ └── Inline Elements (Run, Bold, Italic, Hyperlink, InlineUIContainer)
├── Viewers
│ ├── FlowDocumentScrollViewer (continuous scroll)
│ ├── FlowDocumentPageViewer (page by page)
│ └── FlowDocumentReader (multiple viewing modes)
└── Features
├── Automatic pagination
├── Column layout
├── Figure/Floater positioning
└── Print support
```
---
## 2. Basic FlowDocument
### 2.1 Simple Document
```xml
Document Title
This is a paragraph with bold,
italic, and
underlined text.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```
### 2.2 Document Properties
```xml
```
---
## 3. Block Elements
### 3.1 Paragraph
```xml
Regular paragraph text with indentation.
Highlighted paragraph with background.
```
### 3.2 Section (Grouping)
```xml
First paragraph in section.
Second paragraph in section.
All paragraphs inherit section styling.
```
### 3.3 List
```xml
First item
Second item
Nested item 1
Nested item 2
Step one
Step two
```
**MarkerStyle Options:** None, Disc, Circle, Square, Box, LowerRoman, UpperRoman, LowerLatin, UpperLatin, Decimal
### 3.4 Table
```xml
Name
Description
Price
Item 1
Description of item 1
$10.00
```
### 3.5 BlockUIContainer (Embedding UI)
```xml
```
---
## 4. Inline Elements
### 4.1 Text Formatting
```xml
Normal text
Bold text
Italic text
Underlined text
Code text
Colored text
superscript
```
### 4.2 Hyperlink
```xml
Visit
Example.com
for more info.
```
```csharp
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = e.Uri.AbsoluteUri,
UseShellExecute = true
});
e.Handled = true;
}
```
### 4.3 InlineUIContainer
```xml
Status:
Online
```
---
## 5. Figures and Floaters
### 5.1 Figure (Positioned Content)
```xml
This figure appears at the top-right of the page.
Main document text continues here...
```
**HorizontalAnchor:** ContentLeft, ContentCenter, ContentRight, PageLeft, PageCenter, PageRight
**VerticalAnchor:** PageTop, PageCenter, PageBottom, ContentTop, ContentCenter, ContentBottom
### 5.2 Floater (Floating Content)
```xml
This floater appears inline and text wraps around it.
Main paragraph text that wraps around the floater content...
```
---
## 6. Document Viewers
### 6.1 FlowDocumentScrollViewer
```xml
```
### 6.2 FlowDocumentPageViewer
```xml
```
### 6.3 FlowDocumentReader
```xml
```
---
## 7. References
- [FlowDocument Overview - Microsoft Docs](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/flow-document-overview)
- [Flow Content Elements - Microsoft Docs](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/flow-content-elements-how-to-topics)
- [Documents in WPF - Microsoft Docs](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/documents-in-wpf)