FlowDocument 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 FlowDocument 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| FlowDocument() |
初始化一個新的、空的類別實例 FlowDocument 。 |
| FlowDocument(Block) |
初始化類別的新實例 FlowDocument ,並加入指定的 Block 元素作為初始內容。 |
FlowDocument()
FlowDocument(Block)
初始化類別的新實例 FlowDocument ,並加入指定的 Block 元素作為初始內容。
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)
參數
例外狀況
block 是 null。
範例
下列範例示範使用此建構函式。 在這種情況下,包含 FlowDocument 一個由段落中巢狀的文字執行組成的流程元素區塊結構。
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...")))
以下範例程式化地構造一個簡單的 2 x 2 表格,然後利用建 FlowDocument 構子建立 FlowDocument 包含該表格的新表格。 雖然使用較複雜的流元素區塊結構,但建構子的使用方式與前述範例相同。
// 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)
備註
有效的block輸入類型包括 BlockUIContainer、 List、 Paragraph、 SectionTable和 。