This topic has not yet been rated - Rate this topic

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)
'Declaration
Public Sub New ( _
	block As Block _
)

Parameters

block
Type: System.Windows.Documents.Block

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

ExceptionCondition
ArgumentNullException

block is Nothing.

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.

Dim flowDocSimple As 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.
				Dim tableText As New Paragraph(New Run("A bit of text content..."))

				Dim sampleTable As 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.
            Dim flowDocTable As New FlowDocument(sampleTable)

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.