IWebView2 Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The public interfaces of WebView2 WPF control.
public interface IWebView2
public interface IWebView2 : IDisposable
type IWebView2 = interface
type IWebView2 = interface
interface IDisposable
Public Interface IWebView2
Public Interface IWebView2
Implements IDisposable
- Derived
- Implements
Properties
AllowExternalDrop |
The AllowExternalDrop property for the WebView.
This property directly exposes AllowExternalDrop, see its documentation for more info.
Getting this property before the CoreWebView2Controller has been initialized will retrieve the last value which was
set to it, or |
CanGoBack |
Returns |
CanGoForward |
Returns |
CoreWebView2 |
Accesses the complete functionality of the underlying CoreWebView2 COM API.
Returns |
CreationProperties |
Gets or sets a bag of options which are used during initialization of the control's CoreWebView2. Setting this property will not work after initialization of the control's CoreWebView2 has started (the old value will be retained). See the WebView2 class documentation for an initialization overview. |
DefaultBackgroundColor |
The default background color for the WebView.
This property directly exposes DefaultBackgroundColor, see its documentation for more info.
Getting this property before the CoreWebView2Controller has been initialized will retrieve the last value which was
set to it, or |
DesignModeForegroundColor |
The foreground color to be used in design mode. |
Source |
The top-level Uri which the WebView is currently displaying (or will display once initialization of its CoreWebView2 is finished). Generally speaking, getting this property is equivalent to getting the Source property and setting this property (to a different value) is equivalent to calling the Navigate(String) method. |
ZoomFactor |
The zoom factor for the WebView.
This property directly exposes ZoomFactor, see its documentation for more info.
Getting this property before the CoreWebView2 has been initialized will retrieve the last value which was set to it, or |
Methods
BeginInit() |
Implementation of the ISupportInitialize pattern. Prevents the control from implicitly initializing its CoreWebView2 until EndInit() is called. Does not prevent explicit initialization of the CoreWebView2 (i.e. EnsureCoreWebView2Async(CoreWebView2Environment, CoreWebView2ControllerOptions)). Mainly intended for use by interactive UI designers. |
EndInit() |
Implementation of the ISupportInitialize pattern. Invokes any functionality that has been delayed since the corresponding call to BeginInit(). Mainly intended for use by interactive UI designers. |
EnsureCoreWebView2Async(CoreWebView2Environment, CoreWebView2ControllerOptions) |
Explicitly triggers initialization of the control's CoreWebView2. See the WebView2 class documentation for an initialization overview. |
EnsureCoreWebView2Async(CoreWebView2Environment) |
Explicitly triggers initialization of the control's CoreWebView2. See the WebView2 class documentation for an initialization overview. |
ExecuteScriptAsync(String) |
Executes JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. Equivalent to calling ExecuteScriptAsync(String). |
Focus() |
Attempts to set focus to the WebView2 Control.
Equivalent to calling Focus().
Returns |
GoBack() |
Navigates the WebView to the previous page in the navigation history. Equivalent to calling GoBack() If CoreWebView2 hasn't been initialized yet then does nothing. |
GoForward() |
Navigates the WebView to the next page in the navigation history. Equivalent to calling GoForward(). If CoreWebView2 hasn't been initialized yet then does nothing. |
NavigateToString(String) |
Initiates a navigation to htmlContent as source HTML of a new document. Equivalent to calling NavigateToString(String). |
Reload() |
Reloads the current page. Equivalent to calling Reload(). |
Stop() |
Stops all navigations and pending resource fetches. Equivalent to calling Stop(). |
Events
ContentLoading |
A wrapper around the ContentLoading. The only difference between this event and ContentLoading is the first parameter that's passed to handlers. Handlers of this event will receive the WebView2 control, whereas handlers of ContentLoading will receive the CoreWebView2 instance. |
CoreWebView2InitializationCompleted |
This event is triggered either
|
NavigationCompleted |
A wrapper around the NavigationCompleted. The only difference between this event and NavigationCompleted is the first parameter that's passed to handlers. Handlers of this event will receive the WebView2 control, whereas handlers of NavigationCompleted will receive the CoreWebView2 instance. |
NavigationStarting |
A wrapper around the NavigationStarting. The only difference between this event and NavigationStarting is the first parameter that's passed to handlers. Handlers of this event will receive the WebView2 control, whereas handlers of NavigationStarting will receive the CoreWebView2 instance. |
SourceChanged |
A wrapper around the SourceChanged. The only difference between this event and SourceChanged is the first parameter that's passed to handlers. Handlers of this event will receive the WebView2 control, whereas handlers of SourceChanged will receive the CoreWebView2 instance. |
WebMessageReceived |
A wrapper around the WebMessageReceived. The only difference between this event and WebMessageReceived is the first parameter that's passed to handlers. Handlers of this event will receive the WebView2 control, whereas handlers of WebMessageReceived will receive the CoreWebView2 instance. |
ZoomFactorChanged |
The event is raised when the ZoomFactor property changes. This event directly exposes ZoomFactorChanged. |