I am sure I am missing something simple (still a bit green on this mvvm stuff), but I thought that the use of ViewModelLocator removed the need of DataTemplate binding view to viewmodel. But for some reason I seem to still need it.
In a WPF application I have a window whose only content is a content template which binds to default binding.
<Window ... DataContext="{Binding MainView, Source={StaticResource Locator}}">
<grid><ContentControl Content="{Binding}"/></grid>
I then have a UserControl which I guess you could say is the real view - viewmodel.
<UserControl ...
DataContext="{Binding MainView, Source={StaticResource Locator}}">
...xaml...
</UserControl>
What I have noticed is that unless I place DataTemplate which binds view - viewmodel (MainView in this case) in App.xaml, I just get the name of the class.
Since the window's datacontext is bound using the locator, I thought this would work. My guess is that the additional layer in the window using the ContentControl is confusing things.
If I replace the ContentControl with a direct reference to the view, ie.
<view:MainView />
This also works. So I guess I have two questions: 1. Why does the binding not seem to understand this? 2. Is there a way to get this to work using the locator? I would like to have the window with minimal ui, and keep the bulk in UserControls.
Thank you for any information.
Obscured