Can't load Flowdocuments with xml entites from textfile
i doing a project with the wpf richtextbox control. I'm saving the textfile with the xamlwriter class.
When i'm trying to load the file everything is working really we开发者_开发百科ll except if there are html entities in the file. Because the overloaded XamlReader class only excepts a stream or a XmlReader, the html entities ( in this case '<' (<
) and '>' (>
) are expanded and loaded into the xamlreader where an exception occurs because it thinks '<' is an empty node.
Are there any known workarounds?
Thanks!
Ok.. got it. Loaded the xaml as a stream like so:
public FlowDocument Load(string path)
{
using (StreamReader sReader = System.IO.File.OpenText(path))
{
using (Stream s = sReader.BaseStream)
{
return (FlowDocument)XamlReader.Load(s);
}
}
}
精彩评论