我有以下字符串
<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>Some text <LineBreak /><LineBreak /> <Run FontWeight="bold">Text ...</Run><LineBreak />sjhfdjsgfjsd <LineBreak /><LineBreak /> <Run FontWeight="bold">Text 2 </Run><LineBreak />sdkfskfjsf <LineBreak /><LineBreak /> </Paragraph></FlowDocument>
我尝试使用此代码将其反序列化为FlowDocument,但没有成功。
任何线索我错过了什么?
谢谢!
CODE
StringReader stringReader = new StringReader(xamlString);
XmlReader xmlReader = XmlReader.Create(stringReader);
Section sec = XamlReader.Load(xmlReader) as Section;
FlowDocument doc = new FlowDocument();
while (sec.Blocks.Count > 0)
doc.Blocks.Add(sec.Blocks.FirstBlock);
return doc;
答案 0 :(得分:0)
好的。我找到了。
var stringReader = new StringReader(xamlString);
var xmlReader = XmlReader.Create(stringReader);
var doc= XamlReader.Load(xmlReader) as FlowDocument;