Sharing WPF RichTextBox content with Silverlight RichTextBox

Posted by Stewart Armbrecht on Stack Overflow See other posts from Stack Overflow or by Stewart Armbrecht
Published on 2010-04-18T13:00:03Z Indexed on 2010/04/18 13:03 UTC
Read the original article Hit count: 770

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about silverlight-4.0