WPF RichTextBox的Document属性的序列化与反序列化

序列化:

  string strDocument = System.Windows.Markup.XamlWriter.Save(m_RichTextBox.Document);

保存成字符串的形式

反序列化:

System.IO.StringReader tStringReader = new System.IO.StringReader((string)e.Value);    //其中e.Value是序列化中的string

System.Xml.XmlReader tXmlReader = System.Xml.XmlReader.Create(tStringReader);

FlowDocument tFlowDocument = (FlowDocument)System.Windows.Markup.XamlReader.Load(tXmlReader);

原文地址:https://www.cnblogs.com/sunhappy0318/p/WPF.html