Is there anyway to display HTML from a string variable to the TextBlock in WPF?
TextBlock to Display HTML in WPF
can you be more specific? you want to display a block of HTML as HTML or as formatted (parsed) text? –
Amur
I want to display a block of HTML as formatted text in a TextBlock! I am making a Rss Reader and want to display the description of the rss feed when the user clicks on the title. The description is bind to the TextBlock control. –
Rand
Maybe you can use this WPF Html supported TextBlock
This link is not more available. Pls, update your answer. –
Mestizo
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 ;)
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);
can you please explain where we should find the assembly where Windows.Data.Html.HtmlUtilities is located? I didn't find it in .net framework 4.0, thanks! –
Versicle
its a windows 10 only thing –
Turgeon
the questions is about WPF and i think this answer is for UWP –
Pacesetter
@Pacesetter is right...I have tried in UWP and it was working perfect –
Portamento
:( Can't call this from WPF for some reason (e.g. I can call some other UWP methods not problem) - makes app crash. –
Wanyen
© 2022 - 2024 — McMap. All rights reserved.