簡體   English   中英

在Paragraph.Parent屬性不是FlowDocument的地方有什么有意義的用途?

[英]Is there any meaningful use where the Paragraph.Parent property is not a FlowDocument?

在FlowDocument / WPF RichtTextBox中, Parent屬性的類型為DependencyObject 但是我沒有發現任何有意義的情況,其中Parent不是FlowDocument (或null )。

有沒有?

編輯:

為什么我要知道那個?

我的方法將一個Paragraph作為參數,但我不知道何時調用它。

當Parent為null我知道該段落未集成在任何結構中。

當parent為FlowDocument ,我必須考慮到它的操作。

我是否還考慮到它可能與nullFlowDocument不同?

段落的文檔明確指出:

父級-在邏輯樹中獲取此元素的父級。 繼承自FrameworkContentElement

因此它是繼承的屬性,它必然具有通用的基本類型,並且對於Paragraph在合理的情況下將包含FlowDocument對象。


不需要Paragraph.Parent FlowDocument。 FlowDocument Table官方教程的示例中, new Paragraph(new Run("2004 Sales Project"))的父級是TableCell

// Create and add an empty TableRowGroup to hold the table's Rows.
table1.RowGroups.Add(new TableRowGroup());

// Add the first (title) row.
table1.RowGroups[0].Rows.Add(new TableRow());

// Alias the current working row for easy reference.
TableRow currentRow = table1.RowGroups[0].Rows[0];

// Global formatting for the title row.
currentRow.Background = Brushes.Silver;
currentRow.FontSize = 40;
currentRow.FontWeight = System.Windows.FontWeights.Bold;

// Add the header row with content, 
currentRow.Cells.Add(new TableCell(new Paragraph(new Run("2004 Sales Project"))));
// and set the row to span all 6 columns.
currentRow.Cells[0].ColumnSpan = 6;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM