FlowDocument Xml 序列化
我将 FlowDocument 作为另一个复合对象的一部分,它必须是可序列化的。
[Serializable]
public class RichTextSerializationWrapper
{
public FlowDocument Document { get; set; }
}
所以,我想按如下方式序列化 RichTextSerializationWrapper:
var serializer = new XmlSerializer(typeof(RichTextSerializationWrapper));
TextWriter writer = new StreamWriter(fileName);
serializer.Serialize(writer, richTextSerializationWrapper);
writer.Close();
当然,我得到了异常:
反映类型时出错 'System.Windows.Documents.FlowDocument'。
那么,有人知道如何将 FlowDocument 对象序列化为 XML 吗?
谢谢。
I have FlowDocument as a part of another composite object, what must be serializable.
[Serializable]
public class RichTextSerializationWrapper
{
public FlowDocument Document { get; set; }
}
So, I want serialize RichTextSerializationWrapper as follows:
var serializer = new XmlSerializer(typeof(RichTextSerializationWrapper));
TextWriter writer = new StreamWriter(fileName);
serializer.Serialize(writer, richTextSerializationWrapper);
writer.Close();
And I, of course, get exception:
There was an error reflecting type
'System.Windows.Documents.FlowDocument'.
So, anybody know ways to serialize FlowDocument object into XML?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这个问题:将 FlowDocument 保存到 SQL Server
支持二进制和 XAML 序列化。
According to this question: Saving FlowDocument to SQL Server
Binary and XAML serialization are supported.