5

我试图使用 WinUI,所以我从 Nuget 安装了插件 Microsoft.UI.Xaml (2.4.2) 并按照说明添加 This <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>to my App.Xaml

这是我的 App.Xaml 文件

<Application x:Class="WpfApp1.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApp1"
    StartupUri="MainWindow.xaml">
        <Application.Resources>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        </Application.Resources>
</Application>

但它说:

XML 命名空间“using:Microsoft.UI.Xaml.Controls”中不存在标记“XamlControlsResources”

我尝试了 WinUI 插件的旧版本并尝试了 .Net Core 和 Framework,但仍然遇到此问题

4

2 回答 2

4

I believe this WinUI 2.4.2 library is only compatible if you create a UWP application, not a WPF app.

enter image description here

Having said that, according to this documentation from Microsoft, starting with WinUI 3, you will be able to do this in WPF.

enter image description here

于 2020-06-23T20:09:10.330 回答
1

添加

<package id="Microsoft.UI.Xaml" version="2.5.0-prerelease.200812001" targetFramework="native" />

如果您浏览并找不到它,请将包含上述内容的行添加到 packages.config 文件检查安装并等待还原显示在 Nuget 工具中。

确保参考在<Import Project="packages\Microsoft.UI.Xaml" version="2.5.0-prerelease.200812001..."

以及<Error Condition="!Exists('packages\Microsoft.UI.Xaml" version="2.5.0-prerelease.200812001..." 您项目的 .vcxproj 文件中的内容。

于 2020-11-17T21:38:39.693 回答