Search code examples
.netxamarin.formschromiumwebview2

Can I use WebView2 in Xamarin.Forms? I need to use it in Android, iOS & Windows (UWP), instead of original WebView


I googled and only found the use of WebView2 specifically with Win32 applications.

I searched at NuGet Gallery and found [Microsoft.Web.WebView2] (https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.824-prerelease). This package is only for WinForms and WPF.

Edit (Apr 1, 2022) When I originally asked this question, I had a superficial understanding of the architecture of xamarin.forms applications. What I really meant to ask was: "Is there any cross-platform control, that when used in a xamarin.forms project, uses WebView2 on UWP and the corresponding native WebViews on Android and iOS?" UWP currently uses a WebView that is based on the EDGE browser (pre-Chromium), which is inconvenient.


Solution

  • If you expect to use all native properties, methods and events of WebView2, the answer is that it is impossible and that it won't be possible just like for any other UWP control that is as such limited to UWP.

    If you want just to use the Chromium rendering engine, then on Android you already have it. On iOS you can't use it and it is not possible not just in Xamarin.Forms but in anything. Even Google Chrome and Microsoft Edge apps don't use it. On UWP at the moment you need to write your own custom renderer if you want to use WebView2 in Xamarin.Forms. In some future it will likely work without any additional action.