TextBlock to Display HTML in WPF
Asked Answered
R

3

14

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

Rand answered 1/7, 2009 at 19:50 Comment(2)
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
U
3

Maybe you can use this WPF Html supported TextBlock

Uriel answered 1/3, 2011 at 22:20 Comment(1)
This link is not more available. Pls, update your answer.Mestizo
H
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 ;)

Hausa answered 2/7, 2009 at 6:24 Comment(0)
P
0

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

Portamento answered 9/3, 2016 at 10:7 Comment(5)
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 thingTurgeon
the questions is about WPF and i think this answer is for UWPPacesetter
@Pacesetter is right...I have tried in UWP and it was working perfectPortamento
:( 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.