Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Jun 25, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@bryonac99
Copy link

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

@bryonac99 bryonac99 added the bug Something isn't working label Jun 25, 2024
@pomianowski
Copy link
Member

pomianowski commented Jun 25, 2024

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
Copy link
Author

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
Copy link
Member

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

@bryonac99
Copy link
Author

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
Copy link
Member

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

Would be better full .csproj in zip or repo

@bryonac99
Copy link
Author

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

Would be better full .csproj in zip or repo

Unfortunately I can't share this project..

@pomianowski
Copy link
Member

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

@nabeelio
Copy link

nabeelio commented Aug 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants