Windows 8 Store Apps Learning (8) WebView control

Source: Internet
Author: User
Tags xmlns

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 (" 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.