Previous month:
June 2013
Next month:
August 2013

July 2013

Using the Windows Store App WebView Control with CSS

With Windows 8.1 a major update of the WebView control is available. The updates make the control usable with many different scenarios.

In one project I'm using the WebView control to dynamically get HTML content via a string from a Web service, and make use of a CSS style sheet file that is stored with the Windows Store app.

Loading HTML content from a string can now be done by calling the method NavigateToString:

string htmlContent = service.GetHtml();
webView1.NavigateToString(htmlContent);

Referencing the style sheet that is stored with the Windows Store app is done via the ms-appx-web prefix with the link to the style sheet. The WebView control doesn't support ms-appx, but ms-appx-web is possible:

<link href="ms-appx-web:///css/Styles.css" rel="stylesheet" />

Christian

http://www.cninnovation.com