Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:30:23+00:00 2026-06-15T10:30:23+00:00

I have C# / XAML win store app which receives various data from json.

  • 0

I have C# / XAML win store app which receives various data from json. one piece of it – html string.

I display that string using WebView.NavigateToString

However I don’t see how can I style it. Normally I would use blend to get default style and then edit it. But Blend doesn’t let me style WebView.

I ended up wrapping the json html into

<body style='background-color:black;color:white' />

but this approach doesn’t let me use theming which the rest of the application does.

What is the ‘proper’ way to style and / or format content of the WebView?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:30:25+00:00Added an answer on June 15, 2026 at 10:30 am

    Another solution is making a WebViewContentHelper (or so) class. You may pass the theme and style the CSS according to that. For example:

    string content = WebViewContentHelper.WrapHtml(originalHtmlString, backGroundColor, webView.ActualHeight);
     webView.NavigateToString(content);
    

    You can adapt this class that already copies the Font styling from Windows 8 and gives you horizontal scrolling, also arranges content in columns, just as ItemDetails Template:

    class WebContentHelper
    {
        public static string HtmlHeader(double viewportWidth, double height) //adapt parametres
        {
            var head = new StringBuilder();
            head.Append("<head>");
    
            head.Append("<meta name=\"viewport\" content=\"initial-scale=1, maximum-scale=1, user-scalable=0\"/>");
            head.Append("<script type=\"text/javascript\">"+
                "document.documentElement.style.msScrollTranslation = 'vertical-to-horizontal';"+
                "</script>"); //horizontal scrolling
            //head.Append("<meta name=\"viewport\" content=\"width=720px\">");
            head.Append("<style>");
            head.Append("html { -ms-text-size-adjust:150%;}");
            head.Append(string.Format("h2{{font-size: 48px}} "+
            "body {{background:white;color:black;font-family:'Segoe UI';font-size:18px;margin:0;padding:0;display: block;"+
            "height: 100%;"+
            "overflow-x: scroll;"+
            "position: relative;"+
            "width: 100%;"+
            "z-index: 0;}}"+
            "article{{column-fill: auto;column-gap: 80px;column-width: 500px; column-height:100%; height:630px;"+
            "}}"+
            "img,p.object,iframe {{ max-width:100%; height:auto }}"));
            head.Append(string.Format("a {{color:blue}}"));
            head.Append("</style>");
    
            // head.Append(NotifyScript);
            head.Append("</head>");
            return head.ToString();
        }
        public static string WrapHtml(string htmlSubString, double viewportWidth, double height)
        {
            var html = new StringBuilder();
            html.Append("<html>");
            html.Append(HtmlHeader(viewportWidth,height));
            html.Append("<body><article class=\"content\">");
            html.Append(htmlSubString);
            html.Append("</article></body>");
            html.Append("</html>");
            return html.ToString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my xaml in a string which i render as a grid using
I have generated XAML file from Windows Forms, and with the process calculated right
I have some xaml pasted at the end of this question. It's from a
We have some XAML which may seem odd but apparently is needed for defining
I have a XAML based ScatterView to which I'm programmatically adding more Scatterviews (
I have an app that I'm upgrading from some beta bits - and my
I have a .xaml file which has a listview. Listview has 2 items inside
I have a XAML input form which the user fills out. I want to
I have Page1.xaml and Page2.xaml in Silverlight project. I want to pass query string
I have XAML defining something, say: <Path Data=M16.25,11 L0.5,0.5 L32,0.5 z Fill=#FFF4F4F5 Height=11 Margin=1.542,0.25,18.458,0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.