Question

I'm trying to access the contents of a FlowDocument (of a RichTextBox). I wanna do this because I want to convert the contents to a UBB formatted string (yea, the old forum formated text). Is there a way to get the contents of the FlowDocument's contents:

I know that via FlowDocuments's Blocks property you can get the Blocks inside the FlowDocument, which are itself BlockUIContainer, List, Paragraph, Section or Table objects, as can be seen here. However, if I want the LogicalChildren of Paragraph, for example, its protected and thus inaccessable. So.. This is not the way to go. What is? (I did not find another way, yet.)

Also, I know about converting the contents of a FlowDocument to XAML, etc. But the converters I found, did not include image objects and some other objects I find usefull and are displayed by the RichTextBox.

Thanks in advance!

Was it helpful?

Solution

Ah! I found the solution...

I've been dumb not to think about the ContentPropertyAttribute...

OTHER TIPS

Why not use XmlDocument?

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

There are interesting possiblities e. g. using selection of nodes with xpath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top