我可以在 Silverlight 中渲染 HTML 吗?
有什么方法可以在 Silverlight 中显示格式化文本吗?
我有一个 HTML 格式的文章数据库(p、b、i、h1、h2 标签)。我需要找出一种方法在 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个 HtmlTextBlock 控件 由 David Anson(来自 MS)编写,支持以下 HTML 元素:
幸运的是,源代码是分布式的,您必须提供对
H*
标记的支持。但是,如果您使用的是 Silverlight 4,则可以使用 WebBrowser 类 并将 HTML 加载到其中。请注意(正如 santiagoIT 在评论中所做的那样)WebBrowser 控件仅在您运行浏览器外时才起作用。
There is an HtmlTextBlock control written by David Anson (from MS) which has support for the following HTML elements:
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.
我认为你没有标准的 oob 控件来做到这一点。但我知道有些人开发了自己的控件,例如: http://blogs.msdn.com/b/delay/archive/2007/09/10/bringing- a-bit-of-html-to-silverlight-htmltextblock-makes-rich-text-display-easy.aspx 这很简单,但可以解决您的问题。 ;)
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. ;)