Reputation:
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?
Upvotes: 1
Views: 1221
Reputation: 1664
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/
Upvotes: 1