无法使用Windows社区工具包的GridView控件

发布于 2025-02-01 04:25:32 字数 1388 浏览 4 评论 0原文

我从Windows社区工具包中使用Winui项目中的Windows Community Toolkit获得了GridView控件的问题。我已经添加了Microsoft.toolkit.uwp.ui.control Nuget软件包,该软件包已成功安装,我可以看到它已将其添加到Solution Explorer中的正确项目中。

我的XAML(简短删除了一些无关的代码)如下:

<Window
    x:Class="SampleApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" SizeChanged="SizeChanged"
    mc:Ignorable="d">
        (other controls/content removed for brevity)
        <controls:DataGrid (code removed for brevity)>
        </controls:DataGrid>
</Window>

尝试将控件添加到XAML文件时,行XMLNS:controls =“ use:microsoft.tool.tool.tool.tool.tool.uwp.ui.ui.controls”给出编译器错误:

XLS0429未定义的名称空间。 “使用” URI是指命名空间 'Microsoft.toolkit.uwp.ui.controls',找不到。

...和行启动&lt;控件:datagrid给出编译器错误:

XLS0414找不到类型的“控件:datagrid”。验证您 并没有缺少组装参考,并且全部引用了 已经建立了组件。

我一直在遵循例如这个,但是我什么都没去。

谁能向我指向正确的方向?

I'm having a problem getting the GridView control from the Windows Community Toolkit working in my WinUI project. I've added the Microsoft.Toolkit.Uwp.UI.Control nuget package, which has installed successfully, and I can see it added to the correct project in solution explorer.

My XAML (some irrelevant code removed for brevity) is as follows:

<Window
    x:Class="SampleApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" SizeChanged="SizeChanged"
    mc:Ignorable="d">
        (other controls/content removed for brevity)
        <controls:DataGrid (code removed for brevity)>
        </controls:DataGrid>
</Window>

When trying to add the control to the XAML file, the line xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" gives the compiler error:

XLS0429 Undefined namespace. The 'using' URI refers to a namespace
'Microsoft.Toolkit.Uwp.UI.Controls' that could not be found.

...and the line starting <controls:DataGrid gives the compiler error:

XLS0414 The type 'controls:DataGrid' was not found. Verify that you
are not missing an assembly reference and that all referenced
assemblies have been built.

I've been following examples such as this one, but I'm not getting anywhere.

Can anyone point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独闯女儿国 2025-02-08 04:25:32

您已经使用了标签“ Winui-3”,但您的包装适用于UWP / Winui 2。

选择一个然后重试。

https://www.nuget.org/packages/CommunityToolkit.WinUI.UI .Controls/

You've used the tag 'winui-3' yet your package is for UWP / WinUI 2.

Pick one and try again.

https://www.nuget.org/packages/CommunityToolkit.WinUI.UI.Controls/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文