NativeWebDialog
Overview
NativeWebDialog
is a dialog window that hosts a native web browser implementation. It provides a way to display web content in a separate window, particularly useful for platforms like Linux where embedded WebView controls might not be available.
Properties
Title
public string? Title { get; set; }
Gets or sets the dialog window title.
CanUserResize
public bool CanUserResize { get; set; }
Gets or sets whether the dialog can be resized by the user.
Source
public Uri Source { get; set; }
The URI of the top-level document displayed in the WebView. Setting this property is equivalent to calling Navigate()
.
Default value: about:blank
CanGoBack
public bool CanGoBack { get; }
Indicates whether the WebView can navigate to a previous page in the navigation history.
CanGoForward
public bool CanGoForward { get; }
Indicates whether the WebView can navigate to a next page in the navigation history.
Events
Closing
public event EventHandler Closing;
Fires before the WebView dialog is closed.
AdapterCreated
public event EventHandler<WebViewAdapterEventArgs>? AdapterCreated;
Fires after underlying webview adapter was initialized.
AdapterDestroyed
public event EventHandler<WebViewNavigationCompletedEventArgs>? AdapterDestroyed;
Fires after underlying webview adapter was destroyed.
EnvironmentRequested
public event EventHandler<WebViewEnvironmentRequestedEventArgs>? EnvironmentRequested;
Fired before the underlying webview adapter is created, allowing customization of the webview environment. Use this event to modify environment options (such as enabling private mode or dev tools) before the webview is initialized. The event argument type depends on the platform.
See WebView Environment Options for more details.
NavigationCompleted
public event EventHandler<WebViewNavigationCompletedEventArgs>? NavigationCompleted;
Fires after navigation of the top-level document completes rendering, either successfully or unsuccessfully.
NavigationStarted
public event EventHandler<WebViewNavigationStartingEventArgs>? NavigationStarted;
Fires before a new navigation starts for the top-level document.
NewWindowRequested
public event EventHandler<WebViewNewWindowRequestedEventArgs>? NewWindowRequested;
Fires before a new navigate starts for the top level document.
WebMessageReceived
public event EventHandler<WebMessageReceivedEventArgs>? WebMessageReceived;
Fires after web content sends a message to the app host via invokeCSharpAction(body)
.
WebResourceRequested
public event EventHandler<WebResourceRequestedEventArgs>? WebResourceRequested;
Fires when the WebView is performing a URL request to a matching URL. Arguments include request information, and headers dictionary.
Headers dictionary can be readonly depending on the request or platform.
Always check result of the TrySet
and TryRemove
methods.
Methods
Show
public void Show()
Opens the WebView dialog.
Show (with owner)
public bool Show(IPlatformHandle owner)
Opens the WebView dialog with a specified owner window.
Close
public void Close()
Closes the WebView dialog.
Resize
public bool Resize(int width, int height)
Resizes the dialog window to the specified dimensions.
Move
public bool Move(int x, int y)
Moves the dialog window to the specified screen coordinates.
Navigate
public void Navigate(Uri url)
Navigates the WebView to the specified URI.