Convert XAML to FlowDocument to display in RichTextBox in WPF
Posted
by Erika
on Stack Overflow
See other posts from Stack Overflow
or by Erika
Published on 2010-05-13T23:41:54Z
Indexed on
2010/05/13
23:44 UTC
Read the original article
Hit count: 739
I have some HTML, which i am converting to XAML using the library provided by Microsoft
string t = HtmlToXamlConverter.ConvertHtmlToXaml(mail.HtmlDataString,true);
now, from http://stackoverflow.com/questions/1449121/how-to-insert-xaml-into-richtextbox i am using the following:
private static FlowDocument SetRTF(string xamlString)
{
StringReader stringReader = new StringReader(xamlString);
System.Xml.XmlReader xmlReader = System.Xml.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;
}
This however keeps crashing unfortunately =/ Does anyone have any clue on how to display XAML text in a RichTextBox please?
© Stack Overflow or respective owner