Is it possible to use WebView2 in UWP apps?

Евгений Алексеев 81 Reputation points
2022-02-07T15:45:48.387+00:00

So, according to this documentation: winui2 it is possible to use WebView2 in UWP apps. However, when I try to add the WebView2 component I always get the same 2 errors:

1) XDG0008 The name "WebView2" does not exist in the namespace "using:Microsoft.UI.Xaml.Controls".
2) XLS0414 The type 'control:WebView2' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

I follow the instructions exactly like the website says, yet I always get those errors. My question is, whether or nor it is currently possible to actually use WebView2 component in UWP apps or is there something I do wrong when I try to add the component to my app?

MainPage.xaml code:

<Page  
    x:Class="Internet_Browser.MainPage"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:control="using:Microsoft.UI.Xaml.Controls"  
    xmlns:local="using:Internet_Browser"  
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
    mc:Ignorable="d"  
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">  
  
    <Grid>  
        <control:WebView2 x:Name="wv2" Source="https://bing.com"/>  
    </Grid>  
</Page>  
Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,636 Reputation points
    2022-02-07T16:41:48.91+00:00

    It works for me, with the WinUI2 package :

    171964-microsoftuixaml.jpg


0 additional answers

Sort by: Most helpful