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 Windows Forms. 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")]
[System.Security.SecurityCritical]
[System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.AutoDock)]
public sealed class WebView : System.Windows.Forms.Control, Microsoft.Toolkit.Win32.UI.Controls.IWebView, System.ComponentModel.ISupportInitialize
[<System.Obsolete("The WebView control will be replaced by WebView2 in the future. Read more at https://aka.ms/webview2")>]
[<System.Security.SecurityCritical>]
[<System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.AutoDock)>]
type WebView = class
    inherit Control
    interface IWebView
    interface ISupportInitialize
Public NotInheritable Class WebView
Inherits Control
Implements ISupportInitialize, IWebView
Inheritance
WebView
Attributes
Implements

Remarks

Subset of functionality from Windows.Web.UI.IWebViewControl

Constructors

WebView()

Initializes a new instance of the WebView class.

WebView(WebViewControlProcess)

Defines the base class for controls, which are components with visual representation.

Properties

AllowDrop

Gets or sets a value indicating whether the control can accept data that the user drags onto it.

BackColor

Gets or sets the background color for the control.

BackgroundImage

Gets or sets the background image displayed in the control.

BackgroundImageLayout

Gets or sets the background image layout as defined in the ImageLayout enumeration.

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.

ContainsFullScreenElement

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

Cursor

Gets or sets the cursor that is displayed when the mouse pointer is over the control.

DesignMode

Gets a value indicating whether the WebView is currently in design mode.

DocumentTitle

Gets the document title.

Enabled

Gets or sets a value indicating whether the control can respond to user interaction.

EnterpriseId

Gets or sets an enterprise ID for this process.

Focused

Gets a value indicating whether this WebView is focused.

Font

Gets or sets the font of the text displayed by the control.

ForeColor

Gets or sets the foreground color of the control.

ImeMode

Gets or sets the Input Method Editor (IME) mode of the control.

IsIndexedDBEnabled

Gets or sets a value indicating whether this instance is indexed database enabled.

IsJavaScriptEnabled

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

IsPrivateNetworkClientServerCapabilityEnabled

Gets or sets a value indicating whether this instance is private network client server capability enabled.

IsScriptNotifyAllowed

Gets or sets a value indicating whether ScriptNotify is allowed;

IsSupported

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

Padding

Gets or sets padding within the control.

Process

Gets a WebViewControlProcess object that the control is hosted in.

RightToLeft

Gets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.

Settings

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

Source

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

Text

Gets or sets the text associated with this control.

UseWaitCursor

Gets or sets a value indicating whether to use the wait cursor for the current control and all child controls.

Version

Gets the version of EDGEHTML.DLL used by the control.

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.

Close()

Closes this control.

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.

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.

Events

AcceleratorKeyPressed

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

ContainsFullScreenElementChanged

Occurs when the status of whether the WebView current contains a full screen element or not changes.

ContentLoading

Occurs when the WebView has started loading new content.

DOMContentLoaded

Occurs when the WebView finished parsing the current content.

FrameContentLoading

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

FrameDOMContentLoaded

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

FrameNavigationCompleted

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

FrameNavigationStarting

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

LongRunningScriptDetected

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

MoveFocusRequested

Occurs when a focus move is requested.

NavigationCompleted

Occurs when the WebView control finished navigating to new content.

NavigationStarting

Occurs before the WebView navigates to new content.

NewWindowRequested

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

PermissionRequested

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

ScriptNotify

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

UnsafeContentWarningDisplaying

Occurs when WebView 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 WebView does not support.

UnviewableContentIdentified

Occurs when WebView attempts to download an unsupported file.

Explicit Interface Implementations

ISupportInitialize.BeginInit()

Defines the base class for controls, which are components with visual representation.

ISupportInitialize.EndInit()

Defines the base class for controls, which are components with visual representation.

Applies to

See also