uwp-xaml - 将 WinUI 控件添加到 UWP 应用程序
问题描述
我正在尝试对我的 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>
解决方案
问题是您错过了添加XamlControlsResources
到 UWP 项目 App.xaml 文件中的内容。请将以下 xaml 代码添加到 App.xaml 文件中。
<Application>
<Application.Resources>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
</Application>
更多细节请参考WinUI 官方教程。
推荐阅读
- android - 如何在 Android 中选择文件并计算其哈希值(SHA-256)
- unit-testing - 如何使用 WebStorm 调试 Vue CLI 3 单元测试?调试器未命中断点
- c - socketpair() 可以用来代替 pipe2() 并且应该在所有内核版本中都受支持?
- django - 使用 Django 简单历史创建历史记录的问题
- javascript - 如何使用 jquery .each() 遍历解析的 JSON 数组
- c# - Unity 2D:碰撞触发器
- sas - SAS 中的年度条件总和
- c# - Visual Studio 2017 错误更新 OData 服务参考
- c# - 使用 LINQ 创建简单的 SQL 数据库
- java - 片段数据传输中的片段