Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FlowDocument Constructor (Block)


Initializes a new instance of the FlowDocument class, adding a specified Block element as the initial content.

Namespace:   System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

public FlowDocument(
	Block block


Type: System.Windows.Documents.Block

An object deriving from the abstract Block class, to be added as the initial content.

Exception Condition

block is null.

Valid input types for block include BlockUIContainer, List, Paragraph, Section, and Table.

The following example demonstrates the use of this constructor. In this case, the FlowDocument contains a flow element block structure consisting of a text run nested in a paragraph.

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));

The following example programmatically constructs a simple 2 x 2 table and then uses the FlowDocument constructor to create a new FlowDocument containing the table. Though a somewhat more complicated flow element block structure is used, use of the constructor is the same as in the preceding example.

// A paragraph with sample text will serve as table content.
Paragraph tableText = new Paragraph(new Run("A bit of text content..."));

Table sampleTable = new Table();

// Create and add a couple of columns.
sampleTable.Columns.Add(new TableColumn());
sampleTable.Columns.Add(new TableColumn());

// Create and add a row group and a couple of rows.
sampleTable.RowGroups.Add(new TableRowGroup());
sampleTable.RowGroups[0].Rows.Add(new TableRow());
sampleTable.RowGroups[0].Rows.Add(new TableRow());

// Create four cells initialized with the sample text paragraph.
sampleTable.RowGroups[0].Rows[0].Cells.Add(new TableCell(tableText));
sampleTable.RowGroups[0].Rows[0].Cells.Add(new TableCell(tableText));
sampleTable.RowGroups[0].Rows[1].Cells.Add(new TableCell(tableText));
sampleTable.RowGroups[0].Rows[1].Cells.Add(new TableCell(tableText));

// Finally, use the FlowDocument constructor to create a new FlowDocument containing 
// the table constructed above.
FlowDocument flowDoc = new FlowDocument(sampleTable);

.NET Framework
Available since 3.0
Return to top
© 2016 Microsoft