Kenneth J
Kenneth J

Reputation: 4896

Can I render HTML 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.

Upvotes: 5

Views: 1031

Answers (2)

casperOne
casperOne

Reputation: 74530

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.

Upvotes: 4

Gonçalo Chaves
Gonçalo Chaves

Reputation: 109

I think that you don't have a standard oob control to do that. But I know some guys that develop theirs own control, like this one: http://blogs.msdn.com/b/delay/archive/2007/09/10/bringing-a-bit-of-html-to-silverlight-htmltextblock-makes-rich-text-display-easy.aspx It's simple but can solve your question. ;)

Upvotes: 1

Related Questions