开发者

Can I render HTML in Silverlight?

开发者 https://www.devze.com 2023-02-07 07:18 出处:网络
Is there any way to display formatted text in Silverlight? I have a database of 开发者_如何学Pythonarticles with HTML formatting (p,b,i,h1,h2 tags). I need to figure out a way to display them in a Sil

Is there any way to display formatted text in Silverlight?

I have a database of 开发者_如何学Pythonarticles 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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号