How do you load and save content from a Silverlight 4 RichTextBox control?

I've been reviewing the features of the RichTextBox control in Silverlight 4.

What I've yet to find is any examples of Loading and Saving content in the RichTextBox.

Anyone come across any or can shed some light on it?

The control has a BlocksCollection in which I guess one could use the XamlReader to load a bunch of markup assuming that markup has a single top level node of type Block. Then add that block to the Blocks collection. Seems a shame that the RichTextBox bothers to have a "collection" in this case, why not simply a top-level Block item?

Never-the-less that still leaves saving the content of a RichTextBox, I have no idea where to begin with that one?

I'm sure I must be missing the obvious here but unless loading and saving data in to and from RichTextBox is at least possible if not easy I can't see how we can actually put it to use.


Thanks to DaveB's answer I found discussion of something called the DocumentPersister. However no reference to this class can be found in the MSDN documentation nor can I find it in the installed dlls via object browser search. Anyone, anyone at all?


Check out this tutorial on the RichTextArea control. Persisting content is described in exercise 2, task 3. The code for the tutorial includes a helper class.

Edit: The question was raised about the DocumentPersister class referenced in the tutorial. It is found in the source code download for the tutorial. I think the author created it. By looking at the code you will get an idea as to persisting your data. The only downside was that if your data contained images, the helper class did not support them. Here is the link to the download.

Just to update the link in the accepted answer, it's moved to here:

Need Your Help

fast small angle sinus/cosinus approximation

performance trigonometry approximation

I'm doing some rigid-body rotation dynamics simulation, which means I have to compute many rotations by small angle, which has performance bottleneck in evaluation of trigonometric function. Now I ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.