title: MVVM, Confused about ViewModelLocator and DataTemplate, leading to ViewFirst vs ViewModel first
body: <p>I use MVVMLight and it comes with a ViewModelLocator. </p>
  
  <p>My initial project posed the following problem. I have a MainView that is rendered upon stating up the app. Depending on buttons clicked it renders either View1 or View2 (each are user controls) via ContentControl inside my MainView. </p>
  
  <p>I locate the correct view model in my MainViewModel. But I found that I also need a DataTemplate so that the usercontrols within View1 and View2 will be correctly rendered in MainView, else it would only show the text based name of the classes. </p>
  
  <p>I am confused about the following:</p>
  
  <p>a) Do I need both, a view model locator and a DataTemplate to accomplish the above? I just jumped into WPF but thought I read that one or the other is required not both. Or more specific: Why do I have <code>DataContext="{Binding LiveDataViewModel, Source={StaticResource Locator}}"&gt;</code> in my View (which resolves the binding to its own view model) but still need a DataTemplate?</p>
  
  <p>b) Is this a view model first approach or a view first approach?</p>
  
  <p>c) I tried a code behind solution and it literally took me 4 lines of code to accomplish the exact same thing that took me many classes, detours, eventToCommand &amp; converters [because the control that triggers the choice of view only raises events not commands], data templates, view model locators, different view models...this looks like a huge cost to pay for no advantage whatsoever. Putting this into code behind seems to me perfectly fine because it is pure UI content (choose view and bind to content control, done). Am I missing something here? What would I give up via code behind?</p>
  
  <p>I am new to WPF and MVVM and right now I am just extremely frustrated because it feels like I am running circles around a seemingly trivial issue. </p>