将WinUI控件添加到UWP应用程序

问题描述 投票:0回答:1

我正在尝试对我的UWP应用程序使用新的WinUI工具包TreeView / TeachingTip / ...控件。我已经从Nudget包中添加了对Microsoft.UI.Xaml的引用。

<Page 
    x:Class="UWPInVS2019.Login"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UWPInVS2019"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:WinCon="using:Microsoft.UI.Xaml.Controls"
    mc:Ignorable="d" 
>
<Grid>
<Button />
<WinCon:TeachingTip/>
</Grid>

我收到以下错误消息enter image description here

uwp-xaml
1个回答
0
投票

问题是您错过了将XamlControlsResources添加到UWP项目的App.xaml文件中。请将以下xaml代码添加到App.xaml文件中。

<Application>
    <Application.Resources>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
    </Application.Resources>
</Application>

更多详细信息,请参考WinUI official教程。

© www.soinside.com 2019 - 2024. All rights reserved.