标签'ViewModelLocator“不XML命名空间CLR命名空间存在:XXX [英] The tag 'ViewModelLocator' does not exist in XML namespace clr-namespace:XXX
问题描述
我已经试过许多其他的解决方案,没有任何成功。我有一个名为 ViewModelLocator
这是位于我的便携式类库类。它有一个属性叫的ViewModels
,这类型的百科< K,V>
I have tried numerous other solutions without any success. I have a class called ViewModelLocator
which is located in my portable class library. It has a property in it called ViewModels
, which is of type Dictionay<K, V>
然后,我有一款Windows Phone 8的项目引用便携式类库。我增加了以下到WP8的App.xaml:
Then I have a Windows Phone 8 project that references the portable class library. I added the following to the WP8 app.xaml:
<Application
x:Class="Kaizen.WP8.Test.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:test="clr-namespace:Foo.Core.Portable.ViewModel;assembly=Foo.Core.Portable">
<Application.Resources>
<test:ViewModelLocator x:Key="ViewModelLocator">
<test:ViewModelLocator.ViewModels>
<test:SampleViewModel x:Key="sampleVM"/>
</test:ViewModelLocator.ViewModels>
</test:ViewModelLocator>
</Application.Resources>
</Application>
当我按标签上的F12,其导航到我的PCL正确类或属性。这表明VS知道的对象,但是当我试图和建设,我收到以下错误:
When I press F12 on the tags, it navigates to the correct class and or property in my pcl. Which indicates that VS knows about the objects, but when I try and build, I receive the following error:
标签'ViewModelLocator'呢在XML命名空间
不存在'CLR命名空间:Foo.Core.Portable.ViewModel;装配= Foo.Core.Portable'。
The tag 'ViewModelLocator' does not exist in XML namespace 'clr-namespace:Foo.Core.Portable.ViewModel;assembly=Foo.Core.Portable'.
标签'SampleViewModel 不XML命名空间
存在'CLR命名空间:Foo.Core.Portable.ViewModel;装配= Foo.Core.Portable
The tag 'SampleViewModel' does not exist in XML namespace 'clr-namespace:Foo.Core.Portable.ViewModel;assembly=Foo.Core.Portable'.
任何人都可以请提供一些帮助?
Could anyone please provide some assistance?
[更新]
我引用MVVM光的PCL版本在我的PCL项目。这是 ViewModelLocator
类的样子:
public class ViewModelLocator
{
public dynamic this[string viewModelName]
{
get
{
if (this.ViewModels.ContainsKey(viewModelName))
{
return this.ViewModels[viewModelName];
}
else
{
return null;
}
}
}
public Dictionary<string, ViewModelBase> ViewModels { get; set; }
public ViewModelLocator()
{
this.ViewModels = new Dictionary<string, ViewModelBase>();
}
}
我的WP8项目还使用了MVVM光的PCL组件。我注意到,如果我利用 ViewModelBase
类作为字典值,当我得到的错误。这是因为使用这两个项目之间的MVVM光PCL是一个问题?
[更新]
My WP8 project also makes use of the mvvm light pcl assemblies. I noticed that, if I make use of the ViewModelBase
class as the dictionary value, that when I get the errors. It's as there's an issue using the mvvm light pcl between the two projects?!
[Update]
在事先非常感谢!
亲切的问候,
Many thanks in advance!! Kind regards,
推荐答案
好了,所以我不完全相信我做错了什么在我的第一次尝试,但我重新创建解决方案,并进行或多或少相同的步骤,我没有再收到错误? O_O
Okay, so I'm not exactly sure what I did wrong in my first attempt, but I recreated the solution and performed more or less the same steps and I didn't receive the error again?! o_O
这篇关于标签'ViewModelLocator“不XML命名空间CLR命名空间存在:XXX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!