Introduced
Re-imagine the webview of Windows 8 Store Apps
The basic application of demonstrating WebView
Demonstrates how WebView interacts with JavaScript
Share the content of WebView through Share Contract
How to Full Screen WebView
Example
1, the basic application of WebView
Webview/demo.xaml
<page x:class= "XamlDemo.Controls.WebView.Demo" xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentati On "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" Using:XamlDemo.Controls.WebView "xmlns :d = "http://schemas.microsoft.com/expression/blend/2008" xmlns:mc= "http://schemas.openxmlformats.org/" markup-compatibility/2006 "mc:ignorable=" D "> <grid background=" Transparent "> <stackpanel margin= "0 0 0" > <button name= "btnnavigateurl" content= "navigates to the specified URL" click= "Btnnavigateurl_click_ 1 "/> <button name=" btnshowhtml "content=" parse the specified HTML string "click=" Btnshowhtml_click_1 "M argin= "0 0 0"/> <button name= Btnfullscreen "content=" demonstrates how to manipulate the current page when WebView is full screen (WebView blocks all elements) click= "Btnfullscreen_click_1" margin= "0 0 0"/> <webview name= "WebView" width= "" height= "300" Horizontalalignment= "left" margin= "0 10 00 "/> </StackPanel> </Grid> </Page>
Webview/demo.xaml.cs
* * WebView-Inline Browser * Source-navigates to the specified URL * Navigate ()-navigates to the specified URL * navigatetostring ()-resolves the specified HTML characters
String * loadcompleted-Events triggered after DOM load completed * navigationfailed-events that are triggered when a navigation error occurs (Event parameters: Webviewnavigationfailedeventargs) * Webviewnavigationfailedeventargs * uri-uri * weberrorstatus-Error status (Windows.Web.WebErrorStatus) attempted to navigate to
Enum) * * * using System;
Using Windows.UI.Popups;
Using Windows.UI.Xaml;
Using Windows.UI.Xaml.Controls;
Namespace XamlDemo.Controls.WebView {public sealed partial class Demo:page {public Demo () { This.
InitializeComponent ();
} private void Btnnavigateurl_click_1 (object sender, RoutedEventArgs e) {//Navigate to the specified URL
Webview.navigate (New Uri ("http://webabcd.cnblogs.com/", Urikind.absolute));
Webview.source = new Uri ("http://webabcd.cnblogs.com/", Urikind.absolute); Webview.navigati when navigation failsonfailed + = webview_navigationfailed;
} async void Webview_navigationfailed (object sender, Webviewnavigationfailedeventargs e) { Await new Messagedialog (E.weberrorstatus.tostring ()).
Showasync ();
} private void Btnshowhtml_click_1 (object sender, RoutedEventArgs e) {//parse the specified HTML string
Webview.navigatetostring ("