uwp - TabView suddenly missing from UWP
问题描述
Was trying to implement a TabView in my UWP project yesterday but it doesn't show up in the ToolBox and if I add it via code it says
TabView is not supported in a Windows Universal Project.
Though the documentation on the website is fairly recent and clear: https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/tab-view
I put the UWP requirement on latest Windows 10 build. Running Visual Studio 2019 Enterprise.
More information or help is appreciated.
解决方案
从这个TabView 的文档中可以看到,TabView 在Microsoft.UI.Xaml.Controls命名空间下,适用于 WinUI。因此,您需要安装Microsoft.UI.Xaml nuget 包并将 Windows UI (WinUI) 主题资源添加到您的 App.xaml 资源中。然后在 xaml 中添加命名空间以使用它。
应用程序.xaml:
<Application ...>
<Application.Resources>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
</Application>
MainPage.xaml:
<Page
......
xmlns:control="using:Microsoft.UI.Xaml.Controls">
<Grid>
<control:TabView HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
......
</control:TabView>
</Grid>
</Page>
推荐阅读
- sql - SQL找不到变量?
- xslt - XSL-FO Region-Body 背景图片
- mail-server - 希望创建刻录机帐户
- python - 使用多个 csv 文件作为 CNN 的测试和训练集
- visual-studio - 是在不同的层中复制多个项目文件,还是在创建 Docker 映像时一次性复制更好?
- javascript - 如何在数字输入字段中添加逗号以获取多个重新编码
- swift - 从集合视图重新加载数据时的多个视图
- azure-sql-database - Azure SQL 高级数据安全 (ADS) 和安全中心定价
- leakcanary - 了解 LeakCanary 内存泄漏堆栈跟踪
- c++ - 如何使用new创建指向结构的指针数组?