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);

 

 

posted @ 2012-05-09 09:44  chun0318  阅读(459)  评论(0编辑  收藏  举报