Search code examples
xmlsilverlightxamlserializationrichtextbox

How to get the content of a RichTextBox?


I would like to get the content of a RichTextBox as a string which contains the XAML.

I seen some posts which show differents solutions with another class for parsing the xaml and transforms it into a stringbuilder. But, my goal is to have the XAML directly generated.


Solution

  • At run-time, there are objects like Paragraph, Run, etc. There is no XAML.

    You could serialize the Blocks property, but this will not give you real XAML.

    You are forced to analyze the contents and generate the XAML on the fly.