The DefaultBackgroundColor property is the color WebView renders underneath all web content. This means WebView renders this color when there is no web content loaded such as before the initial navigation or between navigations. This also means web pages with undefined css background properties or background properties containing transparent pixels will render their contents over this color. Web pages with defined and opaque background properties that span the page will obscure the DefaultBackgroundColor and display normally. The default value for this property is white to resemble the native browser experience.
Sets the DefaultBackgroundColor property.
The IsVisible property determines whether to show or hide the WebView2. If IsVisible is set to FALSE, the WebView2 is transparent and is not rendered. However, this does not affect the window containing the WebView2 (the HWND parameter that was passed to CreateCoreWebView2Controller). If you want that window to disappear too, run ShowWindow on it directly in addition to modifying the IsVisible property. WebView2 as a child window does not get window messages when the top window is minimized or restored. For performance reasons, developers should set the IsVisible property of the WebView to FALSE when the app window is minimized and back to TRUE when the app window is restored. The app window does this by handling SIZE_MINIMIZED and SIZE_RESTORED command upon receiving WM_SIZE message.
Sets the IsVisible property.
The WebView bounds. Bounds are relative to the parent HWND. The app has two ways to position a WebView.
Sets the Bounds property.
The zoom factor for the WebView.
Sets the ZoomFactor property.
Adds an event handler for the ZoomFactorChanged event. ZoomFactorChanged runs when the ZoomFactor property of the WebView changes. The event may run because the ZoomFactor property was modified, or due to the user manually modifying the zoom. When it is modified using the ZoomFactor property, the internal zoom factor is updated immediately and no ZoomFactorChanged event is triggered. WebView associates the last used zoom factor for each site. It is possible for the zoom factor to change when navigating to a different page. When the zoom factor changes due to a navigation change, the ZoomFactorChanged event runs right after the ContentLoading event.
Remove an event handler previously added with add_ZoomFactorChanged.
Updates Bounds and ZoomFactor properties at the same time. This operation is atomic from the perspective of the host. After returning from this function, the Bounds and ZoomFactor properties are both updated if the function is successful, or neither is updated if the function fails. If Bounds and ZoomFactor are both updated by the same scale (for example, Bounds and ZoomFactor are both doubled), then the page does not display a change in window.innerWidth or window.innerHeight and the WebView renders the content at the new size and zoom without intermediate renderings. This function also updates just one of ZoomFactor or Bounds by passing in the new value for one and the current value for the other.
Moves focus into WebView. WebView gets focus and focus is set to correspondent element in the page hosted in the WebView. For Programmatic reason, focus is set to previously focused element or the default element if no previously focused element exists. For Next reason, focus is set to the first element. For Previous reason, focus is set to the last element. WebView changes focus through user interaction including selecting into a WebView or Tab into it. For tabbing, the app runs MoveFocus with Next or Previous to align with Tab and Shift+Tab respectively when it decides the WebView is the next element that may exist in a tab. Or, the app runs IsDialogMessage as part of the associated message loop to allow the platform to auto handle tabbing. The platform rotates through all windows with WS_TABSTOP. When the WebView gets focus from IsDialogMessage, it is internally put the focus on the first or last element for tab and Shift+Tab respectively.
Adds an event handler for the MoveFocusRequested event. MoveFocusRequested runs when user tries to tab out of the WebView. The focus of the WebView has not changed when this event is run.
Removes an event handler previously added with add_MoveFocusRequested.
Adds an event handler for the GotFocus event. GotFocus runs when WebView has focus.
Removes an event handler previously added with add_GotFocus.
Adds an event handler for the LostFocus event. LostFocus runs when WebView loses focus. In the case where MoveFocusRequested event is run, the focus is still on WebView when MoveFocusRequested event runs. LostFocus only runs afterwards when code of the app or default action of MoveFocusRequested event set focus away from WebView.
Removes an event handler previously added with add_LostFocus.
Adds an event handler for the AcceleratorKeyPressed event. AcceleratorKeyPressed runs when an accelerator key or key combo is pressed or released while the WebView is focused. A key is considered an accelerator if either of the following conditions are true.
Removes an event handler previously added with add_AcceleratorKeyPressed.
The parent window provided by the app that this WebView is using to render content. This API initially returns the window passed into CreateCoreWebView2Controller.
Sets the parent window for the WebView. This causes the WebView to re-parent the main WebView window to the newly provided window.
This is a notification separate from Bounds that tells WebView that the main WebView parent (or any ancestor) HWND moved. This is needed for accessibility and certain dialogs in WebView to work correctly.
Closes the WebView and cleans up the underlying browser instance. Cleaning up the browser instance releases the resources powering the WebView. The browser instance is shut down if no other WebViews are using it.
Gets the CoreWebView2 associated with this CoreWebView2Controller.