WebUIView WebUIView WebUIView WebUIView WebUIView Class

Definition

Represents a view (window) of the app to the application background script.

public : sealed class WebUIView : IWebUIView, IWebViewControl, IWebViewControl2
struct winrt::Windows::UI::WebUI::WebUIView : IWebUIView, IWebViewControl, IWebViewControl2
public sealed class WebUIView : IWebUIView, IWebViewControl, IWebViewControl2
Public NotInheritable Class WebUIView Implements IWebUIView, IWebViewControl, IWebViewControl2
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10, version 1809 (introduced v10.0.17763.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v7)

Examples

Your app can listen for the NewWebUIViewCreated event to intercept control of the navigation for a new view (exposed from NewWebUIEventCreatedEventArgs.WebUIView):

Windows.UI.WebUI.WebUIApplication.addEventListener("newwebuiviewcreated", newWebUIViewCreatedEventHandler);

Remarks

Windows 10 web apps support an optional per-application background script that starts before any views are activated and runs for the duration of the process. With this, you can monitor and modify navigations, track state across navigations, monitor navigation errors, and run code before views are activated.

When this background script is specified as the StartPage in your app manifest, each of the app's views (windows) are exposed to the script as instances of the WebUIView class, providing the same events, properties, and methods as a general (Win32) WebView.

There are several differences between the HTML webview (x-ms-webview/MSHTMLWebViewElement) and the WebUIView class:

  HTML webview WebUIView class
WebUIView async methods Return MSWebViewAsyncOperation objects Return JavaScript promise objects
Navigate method Requires a URI in the form of a string Requires a Windows.Foundation.Uri object
InvokeScriptAsync method Script arguments are specified as an arbitrary number of string parameters Script arguments are specified as an array of strings

Any app activation with the background script as the StartPage will rely on the script itself for navigation.

Properties

ApplicationViewId ApplicationViewId ApplicationViewId ApplicationViewId ApplicationViewId
CanGoBack CanGoBack CanGoBack CanGoBack CanGoBack

Gets a value that indicates whether there is at least one page in the backward navigation history.

CanGoForward CanGoForward CanGoForward CanGoForward CanGoForward

Gets a value that indicates whether there is at least one page in the forward navigation history.

ContainsFullScreenElement ContainsFullScreenElement ContainsFullScreenElement ContainsFullScreenElement ContainsFullScreenElement

Gets a value that indicates whether the view contains an element that supports full screen.

DefaultBackgroundColor DefaultBackgroundColor DefaultBackgroundColor DefaultBackgroundColor DefaultBackgroundColor

Gets or sets the color to use as the view background when the HTML content does not specify a color.

DeferredPermissionRequests DeferredPermissionRequests DeferredPermissionRequests DeferredPermissionRequests DeferredPermissionRequests

Gets a collection of permission requests that are waiting to be granted or denied.

DocumentTitle DocumentTitle DocumentTitle DocumentTitle DocumentTitle

Gets the title of the page currently displayed in the view.

IgnoreApplicationContentUriRulesNavigationRestrictions IgnoreApplicationContentUriRulesNavigationRestrictions IgnoreApplicationContentUriRulesNavigationRestrictions IgnoreApplicationContentUriRulesNavigationRestrictions IgnoreApplicationContentUriRulesNavigationRestrictions
Settings Settings Settings Settings Settings

Gets a WebViewControlSettings object that contains properties to enable or disable IWebViewControl features.

Source Source Source Source Source

Gets or sets the URI source of the HTML content to display in the control.

Methods

AddInitializeScript(String) AddInitializeScript(String) AddInitializeScript(String) AddInitializeScript(String) AddInitializeScript(String)
BuildLocalStreamUri(String, String) BuildLocalStreamUri(String, String) BuildLocalStreamUri(String, String) BuildLocalStreamUri(String, String) BuildLocalStreamUri(String, String)

Creates a URI that you can pass to NavigateToLocalStreamUri

CapturePreviewToStreamAsync(IRandomAccessStream) CapturePreviewToStreamAsync(IRandomAccessStream) CapturePreviewToStreamAsync(IRandomAccessStream) CapturePreviewToStreamAsync(IRandomAccessStream) CapturePreviewToStreamAsync(IRandomAccessStream)

Creates an image of the current view contents and writes it to the specified stream.

CaptureSelectedContentToDataPackageAsync() CaptureSelectedContentToDataPackageAsync() CaptureSelectedContentToDataPackageAsync() CaptureSelectedContentToDataPackageAsync() CaptureSelectedContentToDataPackageAsync()

Asynchronously gets a DataPackage that contains the selected content within the control.

CreateAsync() CreateAsync() CreateAsync() CreateAsync() CreateAsync()
CreateAsync(Uri) CreateAsync(Uri) CreateAsync(Uri) CreateAsync(Uri) CreateAsync(Uri)
GetDeferredPermissionRequestById(UInt32, WebViewControlDeferredPermissionRequest) GetDeferredPermissionRequestById(UInt32, WebViewControlDeferredPermissionRequest) GetDeferredPermissionRequestById(UInt32, WebViewControlDeferredPermissionRequest) GetDeferredPermissionRequestById(UInt32, WebViewControlDeferredPermissionRequest) GetDeferredPermissionRequestById(UInt32, WebViewControlDeferredPermissionRequest)

Returns the deferred permission request with the specified Id.

GoBack() GoBack() GoBack() GoBack() GoBack()

Navigates to the previous page in the navigation history.

GoForward() GoForward() GoForward() GoForward() GoForward()

Navigates to the next page in the navigation history.

InvokeScriptAsync(String, IIterable<String>) InvokeScriptAsync(String, IIterable<String>) InvokeScriptAsync(String, IIterable<String>) InvokeScriptAsync(String, IIterable<String>) InvokeScriptAsync(String, IIterable<String>)

Executes the specified script function from the currently loaded HTML, with specific arguments, as an asynchronous action.

Navigate(Uri) Navigate(Uri) Navigate(Uri) Navigate(Uri) Navigate(Uri)

Loads the HTML content at the specified Uniform Resource Identifier (URI).

NavigateToLocalStreamUri(Uri, IUriToStreamResolver) NavigateToLocalStreamUri(Uri, IUriToStreamResolver) NavigateToLocalStreamUri(Uri, IUriToStreamResolver) NavigateToLocalStreamUri(Uri, IUriToStreamResolver) NavigateToLocalStreamUri(Uri, IUriToStreamResolver)

Loads local web content at the specified URI using an IUriToStreamResolver.

NavigateToString(String) NavigateToString(String) NavigateToString(String) NavigateToString(String) NavigateToString(String)

Loads the specified HTML content as a new document.

NavigateWithHttpRequestMessage(HttpRequestMessage) NavigateWithHttpRequestMessage(HttpRequestMessage) NavigateWithHttpRequestMessage(HttpRequestMessage) NavigateWithHttpRequestMessage(HttpRequestMessage) NavigateWithHttpRequestMessage(HttpRequestMessage)

Navigates the control to a URI with a POST request and HTTP headers.

Refresh() Refresh() Refresh() Refresh() Refresh()

Reloads the current content in the control.

Stop() Stop() Stop() Stop() Stop()

Halts the current control navigation or download.

Events

Activated Activated Activated Activated Activated

Occurs when the view is activated.

Closed Closed Closed Closed Closed

Occurs when the view has been closed.

ContainsFullScreenElementChanged ContainsFullScreenElementChanged ContainsFullScreenElementChanged ContainsFullScreenElementChanged ContainsFullScreenElementChanged

Occurs when the status of whether the view currently contains a full screen element or not changes.

ContentLoading ContentLoading ContentLoading ContentLoading ContentLoading

Occurs when the view starts loading new content.

DOMContentLoaded DOMContentLoaded DOMContentLoaded DOMContentLoaded DOMContentLoaded

An event that is triggered when the view has finished parsing the current HTML content.

FrameContentLoading FrameContentLoading FrameContentLoading FrameContentLoading FrameContentLoading

Occurs when a frame in the view begins loading new content.

FrameDOMContentLoaded FrameDOMContentLoaded FrameDOMContentLoaded FrameDOMContentLoaded FrameDOMContentLoaded

Occurs when a frame in the view has finished parsing its current HTML content.

FrameNavigationCompleted FrameNavigationCompleted FrameNavigationCompleted FrameNavigationCompleted FrameNavigationCompleted

Occurs when the control has finished loading the current content or if the navigation has failed.

FrameNavigationStarting FrameNavigationStarting FrameNavigationStarting FrameNavigationStarting FrameNavigationStarting

Occurs just before the view navigates to new content.

LongRunningScriptDetected LongRunningScriptDetected LongRunningScriptDetected LongRunningScriptDetected LongRunningScriptDetected

An event that is triggered periodically while the control executes JavaScript, letting you halt the script.

NavigationCompleted NavigationCompleted NavigationCompleted NavigationCompleted NavigationCompleted

Occurs when the control has finished loading the current content or if the navigation has failed.

NavigationStarting NavigationStarting NavigationStarting NavigationStarting NavigationStarting

Occurs before the control navigates to new content.

NewWindowRequested NewWindowRequested NewWindowRequested NewWindowRequested NewWindowRequested

Occurs when a user performs an action in the control that causes content to be opened in a new window.

PermissionRequested PermissionRequested PermissionRequested PermissionRequested PermissionRequested

Occurs when an action in the control requires that permission to be granted.

ScriptNotify ScriptNotify ScriptNotify ScriptNotify ScriptNotify

Occurs when the content contained in the control passes a string to the app using JavaScript.

UnsafeContentWarningDisplaying UnsafeContentWarningDisplaying UnsafeContentWarningDisplaying UnsafeContentWarningDisplaying UnsafeContentWarningDisplaying

Occurs when the control shows a warning page for content that was reported as unsafe by SmartScreen Filter.

UnsupportedUriSchemeIdentified UnsupportedUriSchemeIdentified UnsupportedUriSchemeIdentified UnsupportedUriSchemeIdentified UnsupportedUriSchemeIdentified

Occurs when an attempt is made to navigate to a URI using a scheme that the control doesn't support.

UnviewableContentIdentified UnviewableContentIdentified UnviewableContentIdentified UnviewableContentIdentified UnviewableContentIdentified

An event that is triggered when the control attempts to download an unsupported file.

WebResourceRequested WebResourceRequested WebResourceRequested WebResourceRequested WebResourceRequested

An event that is fired when an HTTP request is made.