I'm developing an application using WinUI 3 with .NET Core 8 and have installed CommunityToolkit.WinUI.Controls, but I'm encountering errors when trying to use SettingsCard in XAML. Here are the error messages I'm receiving:
Error (active) CS0234: The type or namespace name 'Controls' does not exist in the namespace 'CommunityToolkit.WinUI' (are you missing an assembly reference?)
Error XLS0429: Undefined namespace. The 'using' URI refers to a namespace 'CommunityToolkit.WinUI.Controls' that could not be found.
Error XLS0414: The type 'controls:SettingsCard' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
I have added the following lines to my XAML file:
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
And my XAML code looks like this:
<Page
x:Class="Easy_Minecraft_Gui_WinUI3.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Easy_Minecraft_Gui_WinUI3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d"
Background="Transparent">
<Grid>
<StackPanel Spacing="4">
<controls:SettingsCard x:Name="settingsCard"
Description="This is a default card, with the Header, HeaderIcon, Description and Content set."
Header="This is the Header"
HeaderIcon="{ui:FontIcon Glyph=}"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}">
<ComboBox SelectedIndex="0">
<ComboBoxItem>Option 1</ComboBoxItem>
<ComboBoxItem>Option 2</ComboBoxItem>
<ComboBoxItem>Option 3</ComboBoxItem>
</ComboBox>
</controls:SettingsCard>
</StackPanel>
</Grid>
</Page>
I have checked the references and settings, but I'm still unable to resolve this issue. Has anyone encountered a similar problem, and is there any way to fix it?
Thank you!
What I Tried:
Installation of CommunityToolkit.WinUI.Controls: I have installed the
CommunityToolkit.WinUI.Controlspackage via NuGet in my project.XAML Namespace Declarations: I added the appropriate namespace declarations in my XAML file to reference the controls from the toolkit:
xmlns:controls="using:CommunityToolkit.WinUI.Controls" xmlns:ui="using:CommunityToolkit.WinUI"Rebuilding the Project: After adding the references, I rebuilt the project multiple times to ensure all dependencies were correctly resolved.
Cleaning Solution: I cleaned the solution and then rebuilt it to eliminate any caching issues that could cause the error.
Checking for Updates: I ensured that both Visual Studio and the Community Toolkit were updated to their latest versions.
Directory.Packages.propsfile