I want to use a Wpf RichTextBox to edit data and resave it to SQL field. I need of course the text to be saved as rich text, not just simple text of course.
You can save the document to a XAML string using XamlWriter
:
StringWriter wr = new StringWriter();
XamlWriter.Save(richTextBox.Document, wr);
string xaml = wr.ToString();
You can then save the XAML string to a the database like any other text.
To reload it from a XAML string, use XamlReader
:
FlowDocument doc = XamlReader.Parse(xaml) as FlowDocument;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With