3

I am going through some problem In webview, In my webview I am loading local HTMl file with images(Converted as Base64 String) & adding CSS as per our requirement like this,

            MainView.NavigateToString(css.ToString()); //CSS is String Builder

Now I am adding popup on the same page, which have List of text if you Click on text it would be display relevant HTML page in webview,after that I am trying load Html with Horizontal navigation etc.

But webview wont allow any other Control upon it, Because of this Reason I am going for RichTextBlock.

But what is the initial point to load HTML string in RichTextBlock,

Question: How to load HTML string in RichTextBlock or any other Control rather than Webview.

Kumar
  • 864
  • 1
  • 22
  • 46
  • Unfortunately, the WebView I believe is the only way of loading HTML (as content and not just text) into a C#/Xaml app, aside from creating a WinJS/HTML app from the get-go. If you can convert the HTML into XAML, then you can use a `XamlReader` and, more specifically, `XamlReader.Load`. – Nate Diamond Jul 11 '13 at 16:38
  • @NateDiamond I didn't get your intention, After Using `XamlReader` which control I have to use for XAML. Right now I am loading String(Which contains Images,CSS with HTML) in webview. I know I can RichTextBlock for this. But I am wondering about how to make it possible. Thank you for considering my question. – Kumar Jul 12 '13 at 11:09
  • 2
    Check out [this](http://stackoverflow.com/questions/13088034/showing-html-in-winrt-with-richtextblock-or-other-component) answer. Basically, you will need to turn your HTML into XAML controls, such as Grids, Runs, Spans, etc. Then, you can use XamlReader.Load to get your new custom control parsed from your HTML and set it as the content of the RichTextBlock (via its BlockCollection properties). Suffice it to say, it's quite difficult to do. You may want to look into [this](http://html2xaml.codeplex.com/) library, though it has not been updated in a long while, so you may need to tool it a bit. – Nate Diamond Jul 12 '13 at 19:59

1 Answers1

3

You should read this blog post from MSDN "Displaying HTML Content in a RichTextBlock".

If you prefer to jump in, here code from that post.

vsenik
  • 518
  • 5
  • 12
  • It's looking good, I will go through it... & get back to you soon. the sample which you suggested getting error, I have to go for it [http://code.msdn.microsoft.com/windowsapps/Social-Media-Dashboard-135436da/view/Discussions ] Thank you – Kumar Jul 19 '13 at 04:36
  • Excellent! I'm also increasing my level in wpf/winrt – Daniel Apr 13 '16 at 09:28