I need to load/save data from the WPF RichTextBox in a custom format (similar to Markdown).
RichTextBox supports saving/loading in several basic formats (Rtf, Text, Xaml) using TextRange.Save method:
using (FileStream fs = File.OpenWrite(file)) {
TextRange text = new TextRange(rtNote.Document.ContentStart, rtNote.Document.ContentEnd);
text.Save(fs, DataFormats.Xaml);
}
What is the best way to implement the custom format saving/loading?
One way I can think of is to save TextRange to a memory stream as Xaml, parse the resulting XML and iterate over it to do the conversion. Is there an easier way?