Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the elements/objects inside a FlowDocument?

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!

like image 482
van Nijnatten Avatar asked Oct 17 '25 15:10

van Nijnatten


1 Answers

Ah! I found the solution...

  • BlockUIContainer has Child which in return can contain everything else (as long as it inherents from UIElement)
  • It's called Inlines on a Paragraph. This returns a collection of Inline.
  • For List its called ListItems. This contains a collection of ListItem (which in return contains Blocks, thus either of these.
  • A Sections also contains Blocks
  • Table has RowGroups which has a collection of TableRowGroup, etc. etc. etc.

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

like image 193
van Nijnatten Avatar answered Oct 19 '25 14:10

van Nijnatten