You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows provides several controls to embed native WebView inside of the application.
9
-
The same controls can't be supported in cross platform environment, as these browsers are usually tied to a Windows.
9
+
The same controls can't be supported in cross platform XPF environment, as these browsers are usually tied to a Windows.
10
10
11
-
XPF provides an optional control that abstracts over `WebView2` on Windows and `WKWebView` on macOS. Native browsers that don't require any heavy dependencies like Chromium.
12
-
13
-
:::note
14
-
Since Linux doesn't have any standardized built-in native browser, this platform is not currently supported.
15
-
:::
11
+
Instead, XPF provides a webview control is based on Avalonia Accelerate version of [NativeWebView](https://docs.avaloniaui.net/accelerate/components/webview/nativewebview).
12
+
All functionality and configuration documentation can be applied for both.
16
13
17
-
## Installing AvaloniaUI.WebView.Wpf package
14
+
## Installing WebView package
18
15
19
16
First of all, make sure you have installed XPF nuget feed as per [instruction](../build-feeds.md).
20
17
21
18
With nuget feed working, install `Avalonia.Xpf.Controls.WebView` package:
@@ -39,13 +36,19 @@ Typical usage of the NativeWebView looks like this:
39
36
40
37
Where `Source` is a bindable property.
41
38
42
-
## Handling navigation events
39
+
:::note
40
+
Embeddable `NativeWebView` is not supported on Linux.
41
+
Instead, use `NativeWebDialog` there.
42
+
:::
43
+
44
+
45
+
### Handling navigation events
43
46
44
47
`NativeWebView` supports two navigation events:
45
48
-`NavigationStarted` is raised when web page navigation was started. You can read the request Uri from `WebViewNavigationStartingEventArgs.Request`. And it's possible to cancel navigation via `WebViewNavigationStartingEventArgs.Cancel` property. This event also handles redirects.
46
49
-`NavigationCompleted` is raised when web page navigation has completed. And `WebViewNavigationCompletedEventArgs` provides `Request` as well as `IsSuccess` properties.
47
50
48
-
## Bi-directional JavaScript execution
51
+
###Bi-directional JavaScript execution
49
52
50
53
In some situations it's necessary to execute arbitrary JavaScript code from the web view control.
Replace YOUR_CLIENT_ID with the client ID for your application.
117
+
74
118
## Using with native WPF
75
119
76
120
To streamline code migration, it's also possible to use `NativeWebView` control with native WPF on Windows. Without XPF involving.
77
121
78
122
In this scenario, all the API members and underlying browsers are the same. As well as steps to install, the same package can be used.
79
123
80
-
## Platform compatibility:
124
+
## Platform Prerequisites
81
125
82
-
| Feature | Windows WebView2-Edge | Windows IE (fallback) | macOS WKWebView | Linux |
83
-
|---------------|-------|-------|-------|-------|
84
-
|`NativeWebView`| ✔ | ✔ | ✔ | ✖ |
85
-
|`Source`| ✔ | ✔ | ✔ | ✖ |
86
-
|`NavigationStarted`| ✔ | ✔ | ✔ | ✖ |
87
-
|`NavigationCompleted`| ✔ | ✔ | ✔ | ✖ |
88
-
|`WebMessageReceived`| ✔ | ✖ | ✔ | ✖ |
89
-
|`InvokeScript`| ✔ | ✖ | ✔ | ✖ |
126
+
The WebView component relies on native web rendering implementations that must be available on the user's machine:
90
127
91
-
##Accelerate WebView
128
+
### Windows
92
129
93
-
XPF NativeWebView control is based on Avalonia Accelerate version of [NativeWebView](https://docs.avaloniaui.net/accelerate/components/webview/nativewebview).
94
-
All functionality and configuration documentation can be applied for both.
130
+
Uses Microsoft Edge WebView2, which is:
131
+
132
+
- Pre-installed on Windows 11
133
+
- May need installation on Windows 10
134
+
135
+
For Windows 10 users, you can include the WebView2 runtime with your installer:
0 commit comments