简体   繁体   English

HtmlAgilityPack-将HTML转换为XAML并绑定到RichTextBox / TextBlock吗?

[英]HtmlAgilityPack - make HTML to XAML and bind to RichTextBox / TextBlock?

I'm trying to get simple html structures (few < p >, < em >, < i > and stuff) to work with TextBlock or RichTextBox XAML behaviour on WindowsPhone 8. 我正在尝试获取简单的html结构(少量<p>,<em>,<i>和其他东西)以在Windows Phone 8上使用TextBlock或RichTextBox XAML行为。

I found the HtmlAgilityPack and it seems to fit my needs. 我找到了HtmlAgilityPack ,它似乎符合我的需求。 But I do not know how to get correctly formatted XAML code out of the HTML-String. 但是我不知道如何从HTML字符串中获取格式正确的XAML代码。

I've made the following attempt(s): 我做了以下尝试:

        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(data.content);

        doc.OptionOutputAsXml = true;

        MemoryStream str = new MemoryStream();
        XmlWriter outStream = XmlWriter.Create(str);
        doc.Save(outStream);
//How to go on from here? (eg. making a string from the stream?)
//How to assign the XML-String to RichTextBlock?

Check Social Media Dashboard for reference and this article by Tess Ferrandez. 检查社交媒体仪表板以供参考,以及Tess Ferrandez的本文。

http://blogs.msdn.com/b/tess/archive/2013/05/13/displaying-html-content-in-a-richtextblock.aspx http://blogs.msdn.com/b/tess/archive/2013/05/13/displaying-html-content-in-a-richtextblock.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM