TextBlock to Display HTML in WPF

佐手、 提交于 2019-12-06 18:06:36

问题


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



来源:https://stackoverflow.com/questions/1070996/textblock-to-display-html-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!