locked
how to show Html content in Windows 8.1 Store App

    Question

  • I am developing an app in which i need to show some html content but in WebView I have to call Script to disable scrolling which is more of headache because I also need to set the height of webview according to the content. I tried RichTextBlock but it did not show text properly and tags were not parse can somebody help.

    My code is  

    RichTextBlock rtb = new RichTextBlock();
    Paragraph pr = new Paragraph();
    Run runtext = new Run();
    runtext.Foreground = new SolidColorBrush(Windows.UI.Colors.Black);
    runtext.FontSize = 20;
    runtext.Text = obj.description;
    pr.Inlines.Add(runtext);
    rtb.Blocks.Add(pr);
    Grid.SetRow(rtb, 1);
    rtb.Margin = new Thickness(15);            
    DescGrid.Children.Add(rtb);

    Friday, January 9, 2015 1:19 PM

Answers

  • I saw the blog I suggested with you is for Windows Runtime development, it should work with both Windows Store App and Windows Phone.

    Yes, it manage the feed page instead of the String, but it give us an idea how to implement the feature, currently there is no inbox function and we need to write our own code. Otherwise we need to find third party code for help :)

    For example the following code shows how to display the image item by analysis the HTML node.

                    foreach(HtmlNode img in doc.DocumentNode.Descendants("img")){
                        if (!img.Attributes["src"].Value.StartsWith("http"))
                        {
                            img.Attributes["src"].Value = baselink + img.Attributes["src"].Value;
                        }
                    }

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, January 28, 2015 9:04 AM
    Moderator

All replies

  • WebView is obviously the choice number one if you need to keep the formatting (that means that you want to keep the links, paragraphs etc. and not just strip down HTML tags and use plain text), but there's another little known control called HTML TextBlock which was written for Windows Phone 7, but probably could be used or slightly modified to fit Windows 8.1
    Monday, January 12, 2015 2:27 AM
  • Hi RohitrkKUmar,

    Is that means you want to display some HTML content in RichTextBlock instead of in WebView?

    That's possible, please ref to the blog: http://blogs.msdn.com/b/tess/archive/2013/05/13/displaying-html-content-in-a-richtextblock.aspx

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 12, 2015 7:46 AM
    Moderator
  • I tried this but it did not work in WP8.1 and also it directly manages the feed page not the string which i require
    Wednesday, January 14, 2015 10:56 AM
  • I saw the blog I suggested with you is for Windows Runtime development, it should work with both Windows Store App and Windows Phone.

    Yes, it manage the feed page instead of the String, but it give us an idea how to implement the feature, currently there is no inbox function and we need to write our own code. Otherwise we need to find third party code for help :)

    For example the following code shows how to display the image item by analysis the HTML node.

                    foreach(HtmlNode img in doc.DocumentNode.Descendants("img")){
                        if (!img.Attributes["src"].Value.StartsWith("http"))
                        {
                            img.Attributes["src"].Value = baselink + img.Attributes["src"].Value;
                        }
                    }

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, January 28, 2015 9:04 AM
    Moderator