Sharing WPF RichTextBox content with Silverlight RichTextBox
- by Stewart Armbrecht
Has anyone figured out the best way to persist a WPF and Silverlight RichTextBox content so that it can be shared between the two? I haven't had the time to test through this so I wanted to see if anyone else has.
I currently have a WPF applicaiton that saves the content of a RichTextBox as a blob in the database using the following code:
byte[] result = null;
TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
if (range.IsEmpty == false)
{
using (MemoryStream strm = new MemoryStream())
{
range.Save(strm, DataFormats.XamlPackage, true);
result = strm.ToArray();
strm.Close();
}
}
return result;
I am building a silverlight version of the application and want to know how I can load (and save) this content using the Silverlight RichTextBox so that it can still be using in the WPF application.