Load local html file in WebView Metro Style app

c#, microsoft-metro, webview

Solution

You can switch contexts by using the `ms-appx-web:///` protocol instead of `ms-appx:///`, which I've had successfully loading local Html files and associated CSS and JavaScript, within a HTML/JS Metro Style App.

I've not tried this in a XAML Metro Style App, but believe that the `ms-appx-web:///` protocol can be used. The limitation is that your Html (if local i.e not web hosted) has to reside within a WinRT package, which it appears to in your case i.e. /Assets.

Problem

I'm having a bit of trouble loading an html file in a WebView control in a metro style app. I've been searching the internet and found out that you can't load a local html file with the NavigateTo method. I also found out that there is a workaround in which you can use the NavigateToString method of the control. Below is the link where i saw this: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/9cd8614d-2dc8-48ac-9cd9-57b03a644930 Someone in a post on that topic gave an example on how this could be done. They used and a byte array in which they put the data they obtained from calling the IInputstream.ReadAsync method. The problem I've ran into is that after i call that method the byte array is full of 0's, which i don't think is ok. Can anyone help me with this?

Original source