TextBlock to Display HTML in WPF

2020-08-13 05:24发布

问题:

Is there anyway to display HTML from a string variable to the TextBlock in WPF?

回答1:

Maybe you can use this WPF Html supported TextBlock



回答2:

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 ;)



回答3:

string html = "<div>hi</div> <div>&nbsp;</div> <p>this is the new line&nbsp;<br /><br />second line</p> <p>third line</p>";

TextBlock.Text = Windows.Data.Html.HtmlUtilities.ConvertToText(html);



标签: wpf textblock