The name XXX does not exist in the namespace YYY (

2020-08-09 08:10发布

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

标签: xaml
8条回答
何必那么认真
2楼-- · 2020-08-09 08:13

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.

查看更多
劳资没心,怎么记你
3楼-- · 2020-08-09 08:14

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

查看更多
【Aperson】
4楼-- · 2020-08-09 08:20

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.

查看更多
叛逆
5楼-- · 2020-08-09 08:29

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

查看更多
▲ chillily
6楼-- · 2020-08-09 08:30

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.

查看更多
太酷不给撩
7楼-- · 2020-08-09 08:31

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.
查看更多
登录 后发表回答