简体   繁体   中英

What is the equivalent of Android's Html.fromHtml() in WP7?

Is there a quick and dirty way to render HTML in a textblock in a fashion similar to Android's Html.fromHtml() ? I am aware of how to manually parse it with something like the HtmlAgilityPack, but all I really want is for it to render like its source in the textblock.

If not naively then perhaps with a custom control of some sort and, no I don't want to render it as a web page.

Ok sorry it took so long. I all but forgot how to use git correctly and hadn't had the time to upload till now. This HtmlTextBlock offers a similar level of functionality as to that of its silverlight counterpart which is pretty close to the android equivalent. Its still a bit buggy at times when dealing with more complex tags like the html dtd tag but does the job.... WP7 Html Text Block . The design is largely based on this guy's Bringing-a-bit-of-html-to-silverlight-htmltextblock-makes-rich-text-display-easy . and rewriting the web browser related classes using html agility. One day I'll post the details but, blah... Not right now. lol

Update

Example of usage:

<local:HtmlTextBlock x:Name="htmlTextBlock" Canvas.Left="2" Canvas.Top="2" TextWrapping="Wrap" UseDomAsParser="true" Text="&ltp&gtYour Html here </p>" />

Note: Your html will have to be escaped such that &lt = < and &gt = >

For detailed usage see:

https://github.com/musicm122/WP7HtmlTextBlock-/blob/master/HtmlTextBlockTest/HtmlTextBlockTest/MainPage.xaml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM