FlowDocument Konstruktorer

Definition

Initierar en ny instans av FlowDocument klassen.

Överlagringar

Name Description
FlowDocument()

Initierar en ny, tom instans av FlowDocument klassen.

FlowDocument(Block)

Initierar en ny instans av FlowDocument klassen och lägger till ett angivet Block element som det ursprungliga innehållet.

FlowDocument()

Initierar en ny, tom instans av FlowDocument klassen.

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

Gäller för

FlowDocument(Block)

Initierar en ny instans av FlowDocument klassen och lägger till ett angivet Block element som det ursprungliga innehållet.

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

Parametrar

block
Block

Ett objekt som härleds från den abstrakta Block klassen och som ska läggas till som det ursprungliga innehållet.

Undantag

block är null.

Exempel

I följande exempel visas hur konstruktorn används. I det här fallet FlowDocument innehåller innehåller en flödeselementblockstruktur som består av en textkörning kapslad i ett stycke.

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...")))

I följande exempel konstrueras en enkel 2 x 2-tabell programmässigt och konstruktorn används FlowDocument sedan för att skapa en ny FlowDocument som innehåller tabellen. Även om en något mer komplicerad flödeselementblockstruktur används är användningen av konstruktorn densamma som i föregående exempel.

// 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)

Kommentarer

Giltiga indatatyper för block inkluderar BlockUIContainer, List, Paragraph, Sectionoch Table.

Gäller för