Skip to content

Instantly share code, notes, and snippets.

@arn-ob
Last active August 29, 2015 14:10
Show Gist options
  • Save arn-ob/f04f0695f97d7904683c to your computer and use it in GitHub Desktop.
Save arn-ob/f04f0695f97d7904683c to your computer and use it in GitHub Desktop.
WebView code at WinPhon 8.1
/*
paste this to xaml page
<WebView x:Name="WebViewControl"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
NavigationCompleted="Browser_NavigationCompleted" />
*/
public sealed partial class <xaml_page_name> : Page
{
// Replace <html> with your URL here.
// copy all your web doc into a folder then locate the index.html at the code ....
// ex : private static readonly Uri HomeUri = new Uri("ms-appx-web:///Html/index.html", UriKind.Absolute);
private static readonly Uri HomeUri = new Uri("ms-appx-web://<html>", UriKind.Absolute);
public <xaml_page_name>()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
WebViewControl.Navigate(HomeUri);
}
private void Browser_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
if (!args.IsSuccess)
{
Debug.WriteLine("Navigation to this page failed, check your internet connection.");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment