2014-01-24 52 views
0

我正在嘗試訪問FlowDocument(的RichTextBox)的內容。我想這樣做是因爲我想將內容轉換爲UBB格式的string(是的,舊的論壇格式文本)。是否有一種方式來獲得的FlowDocument內容的內容:如何獲取FlowDocument內的元素/對象?

我知道,通過FlowDocumentsBlocks屬性,你可以得到BlocksFlowDocument內,這本身是BlockUIContainerListParagraphSectionTable對象,可以看出here。但是,如果我想ParagraphLogicalChildren,例如,其保護,從而無法訪問。所以..這不是要走的路。什麼是? (我還沒有找到另一種方式)。

此外,我知道如何將FlowDocument的內容轉換爲XAML等。但我發現的轉換器不包括圖像對象和其他一些對象,我覺得它很有用,由RichTextBox顯示。

提前致謝!

回答

0

爲什麼不使用XmlDocument的?

XmlDocument xmlDocument = new XmlDocument(); 
xmlDocument.LoadXml(XamlWriter.Save(richTextBox.Document)); 

有一些有趣的可能性e。 G。使用xpath選擇節點。