FlowDocument Construtores

Definição

Inicializa uma nova instância da classe FlowDocument.Initializes a new instance of the FlowDocument class.

Sobrecargas

FlowDocument()

Inicializa uma nova instância vazia da classe FlowDocument.Initializes a new, empty instance of the FlowDocument class.

FlowDocument(Block)

Inicializa uma nova instância da classe FlowDocument adicionando um elemento Block especificado como o conteúdo inicial.Initializes a new instance of the FlowDocument class, adding a specified Block element as the initial content.

FlowDocument()

Inicializa uma nova instância vazia da classe FlowDocument.Initializes a new, empty instance of the FlowDocument class.

public:
 FlowDocument();
public FlowDocument ();
Public Sub New ()

FlowDocument(Block)

Inicializa uma nova instância da classe FlowDocument adicionando um elemento Block especificado como o conteúdo inicial.Initializes a new instance of the FlowDocument class, adding a specified Block element as the initial content.

public:
 FlowDocument(System::Windows::Documents::Block ^ block);
public FlowDocument (System.Windows.Documents.Block block);
new System.Windows.Documents.FlowDocument : System.Windows.Documents.Block -> System.Windows.Documents.FlowDocument

Parâmetros

block
Block

Um objeto que deriva da classe Block abstrata a ser adicionado como o conteúdo inicial.An object deriving from the abstract Block class, to be added as the initial content.

Exceções

block é null.block is null.

Exemplos

O exemplo a seguir demonstra o uso desse construtor.The following example demonstrates the use of this constructor. Nesse caso, o FlowDocument contém uma estrutura de bloco de elementos de fluxo que consiste em uma execução de texto aninhada em um parágrafo.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...")));
Dim flowDocSimple As New FlowDocument(New Paragraph(New Run("A bit of text content...")))

O exemplo a seguir constrói programaticamente uma tabela 2 x 2 simples e, em seguida, usa o Construtor FlowDocument para criar um novo FlowDocument que contém a tabela.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. Embora uma estrutura de bloco de elementos de fluxo um pouco mais complicado seja usada, o uso do construtor é o mesmo que no exemplo anterior.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);
    ' 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)

Comentários

Os tipos de entrada válidos para block incluem BlockUIContainer, List, Paragraph, Sectione Table.Valid input types for block include BlockUIContainer, List, Paragraph, Section, and Table.

Aplica-se a