WebView Class

Definition

Caution

The WebView control will be replaced by WebView2 in the future. Read more at https://aka.ms/webview2

This class is an implementation of IWebView for WPF. This class cannot be inherited.

[System.Obsolete("The WebView control will be replaced by WebView2 in the future. Read more at https://aka.ms/webview2")]
public sealed class WebView : Microsoft.Toolkit.Wpf.UI.Controls.WebViewHost, Microsoft.Toolkit.UI.Controls.IWebViewCompatible, Microsoft.Toolkit.Win32.UI.Controls.IWebView
[<System.Obsolete("The WebView control will be replaced by WebView2 in the future. Read more at https://aka.ms/webview2")>]
type WebView = class
    inherit WebViewHost
    interface IWebView
    interface IWebViewCompatible
Public NotInheritable Class WebView
Inherits WebViewHost
Implements IWebView, IWebViewCompatible
Inheritance
Attributes
Implements

Constructors

WebView()

Initializes a new instance of the WebView class.

WebView(WebViewControlProcess)

Properties

CanGoBack

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

CanGoForward

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

ChildWindow

Gets the child window.

(Inherited from WebViewHost)
ContainsFullScreenElement

Gets a value indicating whether IWebView contains an element that supports full screen.

DeviceDpi
Obsolete.

Gets the current DPI for this control

(Inherited from WebViewHost)
DocumentTitle

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

DpiScale

Gets the DPI information for which the Visual is measured and rendered.

(Inherited from WebViewHost)
EnterpriseId

Gets or sets an enterprise ID for this process.

IsIndexedDBEnabled

Gets or sets a value indicating whether the use of IndexedDB is allowed.

IsJavaScriptEnabled

Gets or sets a value indicating whether the use of JavaScript is allowed.

IsPrivateNetworkClientServerCapabilityEnabled

Gets or sets a value indicating whether the IsPrivateNetworkClientServerCapabilityEnabled

IsScalingRequired
Obsolete.

Gets a value indicating whether scaling is required for the current DPI.

(Inherited from WebViewHost)
IsScriptNotifyAllowed

Gets or sets a value indicating whether ScriptNotify is allowed.

IsSupported

Gets a value indicating whether WebView is supported in this environment.

IsWebViewVisible

Gets or sets a value indicating whether this instance is web view visible.

ParentHandle

Gets the parent handle.

(Inherited from WebViewHost)
Process

Gets the WebViewControlProcess that the control is hosted in.

Settings

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

Source

Gets or sets the Uniform Resource Identifier (URI) source of the HTML content to display in the IWebView.

Version

Gets the version of EDGEHTML.DLL used by IWebView.

Methods

AddInitializeScript(String)

Adds the script to be loaded before any others on the page.

AddPreLoadedScript(String)
Obsolete.

Adds the script to be loaded before any others on the page.

BeginInit()

Starts the initialization process for this element.

BuildWindowCore(HandleRef)

When overridden in a derived class, creates the window to be hosted.

(Inherited from WebViewHost)
Close()

Closes this instance.

DestroyWindowCore(HandleRef)

Destroys the hosted window.

(Inherited from WebViewHost)
Dispose(Boolean)

Immediately frees any system resources that the WebViewHost might hold.

(Inherited from WebViewHost)
EndInit()

Indicates that the initialization process for the element is complete.

GetDeferredPermissionRequestById(UInt32)

Gets the deferred permission request with the specified Id.

GoBack()

Navigates the IWebView to the previous page in the navigation history.

GoForward()

Navigates the IWebView to the next page in the navigation history.

Initialize()

Initializes this instance.

(Inherited from WebViewHost)
InvokeScript(String)

Executes the specified script function from the currently loaded HTML, with no arguments, as a synchronous action.

InvokeScript(String, IEnumerable<String>)

Executes the specified script function from the currently loaded HTML, with no arguments, as a synchronous action.

InvokeScript(String, String[])

Executes the specified script function from the currently loaded HTML, with no arguments, as a synchronous action.

InvokeScriptAsync(String)

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

InvokeScriptAsync(String, IEnumerable<String>)

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

InvokeScriptAsync(String, String[])

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

MoveFocus(WebViewControlMoveFocusReason)

Moves the focus.

Navigate(String)

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

Navigate(Uri)

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

Navigate(Uri, HttpMethod, String, IEnumerable<KeyValuePair<String,String>>)

Navigates the web view with the URI with a HTTP request and HTTP headers.

NavigateToLocal(String)
Obsolete.

Loads the specified HTML content relative to the location of the current executable.

NavigateToLocalStreamUri(Uri, IUriToStreamResolver)

Loads local web content at the specified Uniform Resource Identifier (URI) using an IUriToStreamResolver.

NavigateToString(String)

Loads the specified HTML content as a new document.

Refresh()

Reloads the current Source in the IWebView.

Stop()

Halts the current IWebView navigation or download.

TranslateAcceleratorCore(MSG, ModifierKeys)

Processes keyboard input at the keydown message level.

(Inherited from WebViewHost)
UpdateBounds(Rect)

Updates the location and size of WebViewHost.

(Inherited from WebViewHost)
UpdateSize(Size)

Updates the size of the WebViewHost using the current visual offset for location.

(Inherited from WebViewHost)
WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean)

When overridden in a derived class, accesses the window process (handle) of the hosted child window.

(Inherited from WebViewHost)

Events

AcceleratorKeyPressed

An event that is triggered when the accelerator key is pressed.

ContainsFullScreenElementChanged

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

ContentLoading

Occurs when the IWebView has started loading new content.

DOMContentLoaded

Occurs when the IWebView finished parsing the current content.

FrameContentLoading

Occurs when a frame in the IWebView has started loading new content.

FrameDOMContentLoaded

Occurs when a frame in the IWebView finished parsing its current content.

FrameNavigationCompleted

Occurs when a frame in the IWebView finished navigating to new content.

FrameNavigationStarting

Occurs when a frame in the IWebView navigates to new content.

LongRunningScriptDetected

Occurs periodically while the IWebView executes JavaScript, letting you halt the script.

MoveFocusRequested

Occurs when a focus move is requested.

NavigationCompleted

Occurs when the IWebView control finished navigating to new content.

NavigationStarting

Occurs before the IWebView navigates to new content.

NewWindowRequested

Occurs when an action is performed that causes content to be opened in a new window.

PermissionRequested

Occurs when an action in a IWebView requires that permission be granted.

ScriptNotify

Occurs when the content contained in the IWebView control passes a string to the application by using JavaScript.

UnsafeContentWarningDisplaying

Occurs when IWebView shows a warning page for content that was reported as unsafe by SmartScreen filter.

UnsupportedUriSchemeIdentified

Occurs when an attempt is made to navigate to a Source using a scheme that IWebView does not support.

UnviewableContentIdentified

Occurs when IWebView attempts to navigate to a content type it cannot render. Like other navigation events, it is only triggered by top level navigations.

Applies to

See also