首页 > 解决方案 > WinUI 3.0 - 为什么 UWP 项目要求 MS Edge for Business 用于 WebView2

问题描述

当我在项目中使用WebView2控件并运行应用程序时,控件内的网页不显示。相反,该应用会显示以下消息,将我带到Microsoft Edge for Business下载页面:UWPWinUI 3.0WebView2

未检测到合适的 Microsoft Edge 版本。请从此处安装最新的 beta 频道版本

问题:为什么它要求使用 Microsoft Edge for Business?我MS Edge Canary ChannelWindows 10 - Pro. 我不想安装太多版本。

MainPage.xaml

<Page
  x:Class="UWP_WinUI.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:UWP_WinUI"
  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>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
        <WebView2 x:Name="wvTest" Grid.Row="1" Source="https://www.bing.com/"/>
    </Grid>
</Page>

应用程序的显示

该网页应该显示在WebVeiw2按钮控件的下方。但相反,会显示消息(如下所示):

在此处输入图像描述

标签: uwpmicrosoft-edgewebviewchromiumwinuiwinui-3

解决方案


对于“WinUI 3.0 Desktop”,它现在是 WebView2 的支持平台,请查看此站点了解详细信息:https ://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winui 。

如果您计划发布您的 WinUI 3.0 应用程序是 UWP 应用程序,那么可能会有一些限制,坦率地说,我不确定该组合。


推荐阅读