Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"does not exist in namespace" error on XAML namespaces

This is an occasional, recurring problem for me. I will make an arbitrary change to my project and in turn VisualStudio will give me 96 namespace errors. They're almost always errors with my XAML namespace declarations, but I know those classes exist in the namespace.

I have cleaned & built, and rebuilt many times, as well as restarting VS with no success.

Examples:

In this case, it is the class ExpandedConverter which "does not exist" in the namespace clr-namespace:NineGridViewer. One possible issue could be that I have organized my project into folders, for example the converters are all in IValueConverters folder and MainWindow is in Views folder. But the namespaces have not changed

enter image description hereenter image description here

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:nineGridViewer="clr-namespace:NineGridViewer"
    Title="NineGridViewer" Height="900" Width="900">
   <Window.Resources>
      <nineGridViewer:ExpandedConverter x:Key="ExpandedConverter"/>
      <nineGridViewer:StringToBrushConverter x:Key="StringToBrushConverter"/>
   </Window.Resources>

namespace NineGridViewer {
/// <summary>
/// Binds the isExpanded property of the UI Expanders to the ViewModel's CurrentExpanded property
/// </summary>
public class ExpandedConverter : IValueConverter
{
    public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        string input = value as string;
        string param = parameter as string;
        if (String.IsNullOrEmpty(input) || String.IsNullOrEmpty(param))
        {
            throw new ArgumentNullException();
        }
        return Equals(input, param);
    }

    public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return parameter;
    }
}
}
like image 684
William Thomas Waller Avatar asked Jul 02 '14 14:07

William Thomas Waller


1 Answers

A compile error is preventing your assembly[ies] from being built, and thus Visual Studio is unable to inspect them and use them in the XAML designer and other tools.

That is why you get all these seemingly missing classes errors.

There should be a "root" error (usually at the bottom of the list), which is a real compile error. If you fix that all other errors should disappear on build.

like image 181
Federico Berasategui Avatar answered Oct 21 '22 01:10

Federico Berasategui