lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.47k stars 725 forks source link

Type or namespace name 'Ui' does not exist in the namespace when I set a name to a wpf-ui component in xaml #1144

Open bryonac99 opened 3 months ago

bryonac99 commented 3 months ago

Describe the bug

Hi, I'm using wpf-ui on my wpf app. It's working, but when I write x:name or name to a component in the xaml it gives me the following error: The type or namespace name 'Ui' does not exist in the namespace 'Client.Wpf' (are you missing an assembly reference?) If I cancel the name or x:name the error will go away.

To Reproduce

Set name or x:name to a wpf-ui component.

Expected behavior

x:name in wpf-ui component working

Screenshots

No response

OS version

Windows 11

.NET version

8.0

WPF-UI NuGet version

3.0.4

Additional context

No response

pomianowski commented 3 months ago

It looks like there is something else in your project whose namespace has *.Client.Wpf.*. Try global::Wpf.Ui or consider changing some names or using's in your files.

bryonac99 commented 3 months ago

It looks like there is something else in your project whose namespace has *.Client.Wpf.*. Try global::Wpf.Ui or consider changing some names or using's in your files.

How do I set global:Wpf.Ui namespce in xaml? It's working on codebehind, but I need it in xaml for x:Name.

pomianowski commented 3 months ago

To understand the error, it would be best if you sent the entire code that would allow to reproduce the error.

bryonac99 commented 3 months ago

In xaml: xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
<ui:Button x:Name="addDeviceBtn" HorizontalAlignment="Left" Appearance="Success" Command="{Binding AddDeviceCommand}" Content="Add Device" Cursor="Hand" Icon="{ui:SymbolIcon Add24}" /> Error CS0234: The type or namespace name 'Ui' does not exist in the namespace 'MyApp.App.Wpf' (are you missing an assembly reference?) If I remove x:Name the error goes away

pomianowski commented 3 months ago

In xaml: xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" Error CS0234: The type or namespace name 'Ui' does not exist in the namespace 'MyApp.App.Wpf' (are you missing an assembly reference?) If I remove x:Name the error goes away

Would be better full .csproj in zip or repo

bryonac99 commented 3 months ago

In xaml: xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" Error CS0234: The type or namespace name 'Ui' does not exist in the namespace 'MyApp.App.Wpf' (are you missing an assembly reference?) If I remove x:Name the error goes away

Would be better full .csproj in zip or repo

Unfortunately I can't share this project..

pomianowski commented 3 months ago

You don't have to send the project, just the minimal code that causes the error

nabeelio commented 1 month ago

I ran into this now, with a project being named xyz.Client.Wpf - and also xyz.Client.UI.Wpf - I renamed the project and root namespaces to xyz.Client.Windows (getting rid of the Client and Wpf parts, and it worked.

Try renaming the project so it doesn't end/have .Wpf, same for all the namespaces