Can the MVVM-Light ViewModelLocator be used in nested ViewModels?
Posted
by dthrasher
on Stack Overflow
See other posts from Stack Overflow
or by dthrasher
Published on 2010-06-10T00:34:52Z
Indexed on
2010/06/10
0:42 UTC
Read the original article
Hit count: 570
The Visual Studio 2008 Designer doesn't seem to like UserControls that reference the MVVM-Light ViewModelLocator. I get an error message like:
Could not create an instance of type 'MyUserControl'.
For example, the following XAML will cause this behavior if MyUserControl uses the ViewModelLocator to establish its DataContext.
<Page x:Class="MyProject.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Views="clr-namespace:MyProject.Views"
>
<Grid>
<Views:MyUserControl/>
</Grid>
</Page>
Is the ViewModelLocator only meant to be used in top-level Views?
© Stack Overflow or respective owner