Ken Cone
Ken Cone

Reputation: 470

The name XXX does not exist in the namespace YYY (XAML VS12 Windows 8)

So I'm working in VS12 on Windows 8, and hacking the ContosoCookbook code to make a different app. I'm trying to set up a "MainMenu.xaml" page and in I have:

        <CollectionViewSource
        x:Name="groupedItemsViewSource"
        Source="{Binding Groups}"
        IsSourceGrouped="true"
        ItemsPath="TopItems"
        d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:FlashCardDataSource, IsDesignTimeCreatable=True}}"/>

The error I'm getting is: The name "FlashCardDataSource" does not exist in the namespace "using:FlashCards.Data".

...but I don't understand how it doesn't. Where do I start looking? I'm new at XAML.

-Ken

Upvotes: 18

Views: 15330

Answers (8)

user1461439
user1461439

Reputation: 11

If you are certain the class is present in the right namespace, just right click on the project in VS and choose Unload. Then Reload the project. This makes it re-evaluate all the namespaces and was the only cure for the issue I've found (when it really persistently won't acknowledge you classes;)

Upvotes: 1

Tim
Tim

Reputation: 1118

None of the above worked for me, but simply adding another dummy class to the folder containing the class it claimed did not exist seemed to do the trick. Maybe it made VS have another look.

Upvotes: 0

yu yang Jian
yu yang Jian

Reputation: 7171

In my case, I clean all the property value relative to the binding I assign by code in all class, then all become normal.

I think if giving value to the property that using in bindings at the same time in some wrong position in class will cause problem, so remove all the assignment code relative to the property may help.

Upvotes: 0

Captain Kenpachi
Captain Kenpachi

Reputation: 7215

Generally this error is caused by one of the following:

  1. You haven't referenced the assembly that the class is in.
  2. You haven't updated the reference to the assembly after adding the class to it.
  3. You are referencing the wrong version of the assembly.
  4. You are referencing the .DLL file instead of the project (in the case where the project is part of your solution)
  5. There is a syntax error in the class you are referencing.

Upvotes: 5

QuantumHive
QuantumHive

Reputation: 5683

Check every class and xaml file for namespaces (even in App.xaml and MainWindow.xaml). Make sure you are not confusing the x:Class in the top element of the file with a namespace. Sometimes it indeed looks like a bug, but it's just one namespace somewhere that's independent of everything else that mixes up everything.

Upvotes: 2

Maxiss
Maxiss

Reputation: 1056

If nothing else is possible, comment the lines which use the namespace, rebuild, and then build the full project again.

I also tried rebuilding the project, reopening Visual Studio. Nothing helped. I finally commented xaml, rebuilt the project, uncommented xaml and it finally worked! Strange issue.

Upvotes: 18

ApoorvaJ
ApoorvaJ

Reputation: 830

If cleaning and rebuilding does not help, try restarting Visual Studio. Worked for me.

Upvotes: 12

Junfeng Dai
Junfeng Dai

Reputation: 116

Did you try to rebuild your project? Maybe clean the project and rebuild again.

Upvotes: 2

Related Questions