Search code examples
wpfxaml

The tag 'XXX' does not exist in XML namespace 'clr-namespace:YYY'


I have implemented a converter to convert Int32 to String to be able to binding a property to a textBox.

I implement this converter in the namespace MyApp.Converters and it is called Int32ToStringConverter.

Then, in my axml I add the reference to my converter as follow:

<Window x:Class="MusicaDB.Views.PrincipalView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        **xmlns:converter="clr-namesapce:MyApp.Converters, aseembly=MyApp**">

Later, in windows.Resources I have:

<Window.Resources>
        <**converter:Int32ToStringConverter** x:Key="Int32ToStringConverter" />
</Window.Resources>

I get the error that the tag Int32ToString converter does not exist in the namespace MyApp.Converters,assembly=MyApp.

I have the project in the local hard drive, in the project properties, the destination .NET is framework 4.0, not framework 4.0 client profile and I try to clear the solution and recompile but the problem persists.

Mainly, this is the two solutions that I always find, but don't resolve my problem.


Solution

  • Three fixes to make here:

    1. No spaces -> xmlns:converter="clr-namesapce:MyApp.Converters,aseembly=MyApp"
    2. No misspellings -> xmlns:converter="clr-namespace:MyApp.Converters,assembly=MyApp"
    3. Right delimiters -> xmlns:converter="clr-namespace:MyApp.Converters;assembly=MyApp"

    From the the documentation:

    Note that the character separating the clr-namespace token from its value is a colon (:) whereas the character separating the assembly token from its value is an equals sign (=). The character to use between these two tokens is a semicolon. Also, do not include any whitespace anywhere in the declaration.