Share via


BlazorWebView Class

Definition

A Windows Forms control for hosting Razor components locally in Windows desktop applications.

public ref class BlazorWebView : System::Windows::Forms::ContainerControl
public class BlazorWebView : System.Windows.Forms.ContainerControl
type BlazorWebView = class
    inherit ContainerControl
Public Class BlazorWebView
Inherits ContainerControl
Inheritance
BlazorWebView

Constructors

BlazorWebView()

Creates a new instance of BlazorWebView.

Fields

BlazorWebViewInitialized

Allows customizing the web view after it is created.

BlazorWebViewInitializing

Allows customizing the web view before it is created.

UrlLoading

Allows customizing how links are opened. By default, opens internal links in the webview and external links in an external app.

Properties

HostPage

Path to the host page within the application's static files. For example, wwwroot\index.html. This property must be set to a valid value for the Razor components to start.

RootComponents

A collection of RootComponent instances that specify the Blazor IComponent types to be used directly in the specified HostPage.

Services

Gets or sets an IServiceProvider containing services to be used by this control and also by application code. This property must be set to a valid value for the Razor components to start.

StartPath

Path for initial Blazor navigation when the Blazor component is finished loading.

WebView

Returns the inner WebView2 used by this control.

Methods

CreateControlsInstance()

Creates a new instance of the control collection for the control.

CreateFileProvider(String)

Creates a file provider for static assets used in the BlazorWebView. The default implementation serves files from disk. Override this method to return a custom IFileProvider to serve assets such as wwwroot/index.html. Call the base method and combine its return value with a CompositeFileProvider to use both custom assets and default assets.

Dispose(Boolean)

Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.

OnCreateControl()

Raises the CreateControl() method.

TryDispatchAsync(Action<IServiceProvider>)

Calls the specified workItem asynchronously and passes in the scoped services available to Razor components.

Applies to