The tag 'XamlControlsResources' does not exist in XML namespace 'using:Microsoft.UI.Xaml.Controls'
Asked Answered
E

2

6

I was trying to use WinUI so I installed the plugin Microsoft.UI.Xaml (2.4.2) from Nuget and followed the instructions which says add This <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/> to my App.Xaml

and here is my App.Xaml file

<Application x:Class="WpfApp1.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApp1"
    StartupUri="MainWindow.xaml">
        <Application.Resources>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        </Application.Resources>
</Application>

but it says:

The tag 'XamlControlsResources' does not exist in XML namespace 'using:Microsoft.UI.Xaml.Controls'

i tried older versions from WinUI plugin and tried .Net Core and Framework but still having this problem

Expansile answered 23/6, 2020 at 18:16 Comment(1)
In my case, I installed a WPF library that causes this exception. After removing that library, my application works fine.Grasping
T
5

I believe this WinUI 2.4.2 library is only compatible if you create a UWP application, not a WPF app.

enter image description here

Having said that, according to this documentation from Microsoft, starting with WinUI 3, you will be able to do this in WPF.

enter image description here

Theomania answered 23/6, 2020 at 20:9 Comment(1)
yea you are right, i was going to delete my question after reading those documents but found out that you answered me already so i accepted the question and im gonna keep it, thanks for the answer :)Expansile
P
1

Add

<package id="Microsoft.UI.Xaml" version="2.5.0-prerelease.200812001" targetFramework="native" />

If you browse and can't find it add a line containing the above to the packages.config file check installed and the wait for Restore to show up in Nuget tools.

Make certain a reference is in the <Import Project="packages\Microsoft.UI.Xaml" version="2.5.0-prerelease.200812001..."

And also the <Error Condition="!Exists('packages\Microsoft.UI.Xaml" version="2.5.0-prerelease.200812001..." in the .vcxproj file for your project.

Peppy answered 17/11, 2020 at 21:38 Comment(1)
actually i was supposed to use UWP but i didnt know that at first, i was using WPF thats why it wasn't working, but thanks anywaysExpansile

© 2022 - 2024 — McMap. All rights reserved.