C# 如果段落.Parent属性不是FlowDocument,是否有任何有意义的用途?
在FlowDocument/WPF RichtTextBox中,C# 如果段落.Parent属性不是FlowDocument,是否有任何有意义的用途?,c#,wpf,richtextbox,flowdocument,C#,Wpf,Richtextbox,Flowdocument,在FlowDocument/WPF RichtTextBox中,父属性的类型为DependencyObject。但我还没有发现任何有意义的情况,即父项不是FlowDocument(或null) 有吗 编辑: 为什么我要知道 我的方法得到一个段落作为参数,我不知道何时调用它 当Parent为null时,我知道该段落没有整合到任何结构中 当父级为FlowDocument时,我必须将其考虑到我的操作中 我是否也考虑到它可能不同于null或FlowDocument?文档清楚地说明: 父级-获取此元素在逻
父属性的类型为DependencyObject
。但我还没有发现任何有意义的情况,即父项不是FlowDocument
(或null
)
有吗
编辑:
为什么我要知道
我的方法得到一个段落
作为参数,我不知道何时调用它
当Parent为null
时,我知道该段落没有整合到任何结构中
当父级为FlowDocument
时,我必须将其考虑到我的操作中
我是否也考虑到它可能不同于null
或FlowDocument
?文档清楚地说明:
父级-获取此元素在逻辑树中的父级。(继承自FrameworkContentElement)
所以它是继承的属性,它必须具有公共的基类型,对于段落,在合理的情况下将包含FlowDocument
对象
段落。父项不是流程文档所必需的。在中的示例中,新段落(新运行(“2004年销售项目”)
段落的父级是一个表格单元格
:
// 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;
请给我一个提示这个问题出了什么问题。