I have tried many other solutions without any success. I have a class called ViewModelLocator which is in my portable class library. It has a property in it called ViewModels , which is of type Dictionay<K, V>
Then I have a Windows Phone 8 project that references a 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>
When I click F12 on tags, it goes to the correct class and / or property in my pcl. Which indicates that VS knows about objects, but when I try to build, I get the following error:
The tag 'ViewModelLocator' does not exist in the XML namespace. 'CLR names: Foo.Core.Portable.ViewModel; assembly = Foo.Core.Portable '
The tag 'SampleViewModel' does not exist in the XML namespace. 'CLR names: Foo.Core.Portable.ViewModel; assembly = Foo.Core.Portable '
Can someone provide some help?
[Update] I am referring to the pcl version of mvvm light in my pcl project. This is what the ViewModelLocator class looks like:
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>(); } }
My WP8 project also uses mvvm light pcl builds. I noticed that if I use the ViewModelBase class as a dictionary value, this is when I get errors. Is this like a problem using mvvm light pcl between two projects ?! [Update]
Thank you very much in advance! Yours faithfully,