问题
Is there anyway to display HTML from a string variable to the TextBlock in WPF?
回答1:
Can't do it in TextBlock, you need a WebBrowser control (or Frame, but it is obsolete). Feed descriptions, btw, can contain JavaScript - would be pretty hard for TextBlock to handle ;)
回答2:
Maybe you can use this WPF Html supported TextBlock
回答3:
string html = "<div>hi</div>
<div> </div>
<p>this is the new line <br /><br />second line</p>
<p>third line</p>
";
TextBlock.Text = Windows.Data.Html.HtmlUtilities.ConvertToText(html);
来源:https://stackoverflow.com/questions/1070996/textblock-to-display-html-in-wpf