Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying formatted text in Silverlight

Is there any way to display formatted text in Silverlight?

I have a database of articles with HTML formatting (p,b,i,h1,h2 tags). I need to figure out a way to display them in a Silverlight application while retaining the formatting from the database.

like image 795
Kenneth J Avatar asked Jan 27 '11 20:01

Kenneth J


1 Answers

There is an HtmlTextBlock control written by David Anson (from MS) which has support for the following HTML elements:

  • A
  • B
  • BR
  • EM
  • I
  • P
  • STRONG
  • U

Fortunately, the source is distributed, and you'd have to provide support for H* tags.

However, if you are using Silverlight 4, then you can use the WebBrowser class and just load your HTML into that. Just note (as santiagoIT does in the comments) that the WebBrowser control will only work if you are running out-of-browser.

like image 122
casperOne Avatar answered Sep 30 '22 16:09

casperOne