Class WebViewHandler<TJsInterop>

This class is a wrapper around the WebView control to make it easier to use inside of a WPF application.

To use it in your WPF app, create a property of the WebViewHandler type and initialize it in your Window CTOR after InitializeComponent passing in the WebBrowser control and

System.Object
  Westwind.WebView.Wpf.WebViewHandler<TJsInterop>
public class WebViewHandler<TJsInterop> : object, IDisposable

Class Members

MemberDescription

Constructor

IMPORTANT! Please ensure that you call InitializeAsync() explicitly: wvh = new WebViewHandler(webView, null, null); _ = wvh.InitializeAsync();

Dispose

public virtual void Dispose()

InitializeAsync

Initializes the control - you can override this but make sure you call base() to call original functionality

public virtual Task InitializeAsync()

Navigate

Navigates the browser to a URL or file

public void Navigate(string url)

public void Navigate(Uri uri)

Refresh

Reloads the Web Browser control with the current content

public void Refresh(bool noCache)

ShowDeveloperTools

Opens the developer tools. If you want tools to open on startup make sure you call this immediately after instantiating the object.

public void ShowDeveloperTools()

ClientBaseObjectName

ExitApplicationOnWebViewCrash

If set to true a WebView crash will display an error message and exit the application. Otherwise the error is ignored or you can override the OnProcessFailed handler.

HostObject

An object that can be called from JavaScript code and passed to the Web Browser.

This object MUST BE SET DURING INITIALIZATION

HostObjectName

The name of the host object passed to JavaScript for callbacks.

HostWebHostNameForFolder

The domain URL that is mapped to the local folder if HostWebRootFolder is set.

HostWebRootFolder

Optional folder that is mapped to HostWebHostNameForFolder. If this value is set the host mapping is made, otherwise no host mapping is done.

IsInitialized

Property that is set after the control is initialized and ready to receive navigation commands

IsLoaded

Property set once content has loaded for the first time.

IsVisible

Shortcut to visibility setting

JsInterop

Object that can be used to access JavaScript operations on the Preview window. Runs global functions in the document using CallMethod()

WebBrowser

The underlying WebBrowser instance. Exposed here so we can override properties and hook events if necessary.

WebViewEnvironmentFolder

The full folder path name where WebView environment is stored. If not set a standard folder is created in the TEMP path.

Requirements

Namespace: Westwind.WebView.Wpf
Assembly: markdownmonster.exe

© West Wind Technologies, 2016-2023 • Updated: 11/23/21
Comment or report problem with topic