3

我正在使用 WinUI 3.0 在 C# 中制作 UWP Windows 应用程序,几天前我开始遇到这种错误:

CS0433  The type 'NavigationView' exists in both 'Microsoft.UI.Xaml, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Microsoft.UI, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'

这是导致错误的自动生成代码的片段:

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 0.0.0.0")]
        private global::Microsoft.UI.Xaml.Controls.NavigationView settingsNavPane; 

到目前为止,我通过删除/bin/obj的内容解决了这个问题的实例,但问题似乎仍然存在。

我知道这是一个编译器错误,所以我尝试添加对 .csproj 文件的引用:

<References>
  <Reference Include="Microsoft.UI.Xaml.dll"/>
</References>

我不知道我是否遗漏了一些明显的东西,但这也没有解决问题。我该如何解决?

4

1 回答 1

0

从您的错误中得出,看起来您没有具体XamlControlsResources的,请参阅此文档并将 XamlControlsResources 添加到您的 app.xaml 文件中。

<Application.Resources>
    <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
于 2021-07-06T07:26:06.597 回答