Showing Html in WinRT with RichTextBlock or other component

I want to show html in string with some component. Now I am using RichTextBlock and I tried few extensions for converting html to xaml or rtf but I didn´t found any working with WinRT. I know I can use WebView but it isn´t so pretty. I just want to do little change to ItemDetailPage (where is used RichTextBlock) to show users elementary html (bold, italics, links, images, ...).

Is there some component or some way how to do this (not webview)? Or is there working convertor?


You have 2 ways

  • build or get your own html to xaml parser to use the contents as RichTextBox Source
  • Use WebView to display html content
  • I recommend WebView because this componente have a lot of features that is very difficult to implement as a parser

  • javascript support
  • css support
  • bad formed (real world) html support
  • etc
  • So, in a WebView control you can use WebView.NavigateToString method to display html contents stored in a string.

    Yo can, even, modify string to changes styles, add scripts, etc as you need to custom webview look and feel.

    NavigateToString has no support for binding but I wrote an article (spanish) teaching how to doing using attached properties: http://blogs.msdn.com/b/juank/archive/2012/10/29/tutorial-crear-app-lector-rss-winrt-parte-7.aspx

    Use this code(plex) to parsing , if it not fit exactly you can change te code for your own. ;) http://html2xaml.codeplex.com/

    Other wise you would create the ode yourself, if you want break pages in column text (to horizontal reading) you must use RichTextBlock, use RichTextColumns hepler class ( included in Common/ folder when you start your app from a template) and try to parse HTML to XAML.


    I finally got fed up with the lack of WinRT-supported Html to Xaml conversion and wrote my own. For kicks, I put it on codeplex. For even further kicks, and to experiment with NuGet, I published it there, too...

    Obviously, this isn't the end-all of Html to Xaml conversion, but it's a start...


    I have implemented a library which parses HTML and renders the HTML using native controls. The component is very flexible and extensible.

    Have a look at:

  • http://mytoolkit.codeplex.com/wikipage?title=HtmlTextBlock
  • 链接地址: http://www.djcxy.com/p/67374.html

    上一篇: CSS / HTML:什么是使文本斜体的正确方法?

    下一篇: 用RichTextBlock或其他组件在WinRT中显示Html