Is it possible to use the MVVMLight ViewModelLocator on a UserControl. I have added it to my user control in the same way as is done on the MainWindow, but i get an error/popup in VS2010 stating "Cannot find resource named 'Locator'. Resource names are case sensitive."
Has anyone tried this?
Code i have thus far is pretty much a standard MVVMLight WPF starter application...
UserControl
<UserControl x:Class="NavTest3.PersonControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Height="116" MinWidth="250" Width="300"
DataContext="{Binding Person, Source={StaticResource Locator}}"
>
<!---->
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Skins/MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
App.xaml contains..
<Application.Resources>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
</Application.Resources>
so the issue is with setting "DataContext="{Binding Person, Source={StaticResource Locator}}" on the userControl."
As mentioned, doing this will mean every instance of this user control will share the same ViewModel, but I want to start with understanding this issue before moving on..