title: WPF - Use a single Model with multiple ViewModels
body: <p>How would you allow multiple viewmodels to share the same model?</p>
  
  <p>I'm creating the viewmodels in an ApplicationViewModel that is used for switching between views using a DataTemplate with the selected VM.</p>
  
  <pre><code>public ApplicationViewModel()
  {
      //Add pages
      BasePageViewModels.Add("Home Page", new HomeViewModel());
      BasePageViewModels.Add("Summary Page", new SummaryViewModel());
      BasePageViewModels.Add("AddTestRun Page", new AddTestRunViewModel());
      //some code here
      CurrentBasePageViewModel = BasePageViewModels["Home Page"];
  }
  </code></pre>
  
  <p>I want to be able to access the same Data class from within each of the created VM's.
  Ideally I'd pass in the Data class to each ViewModel with a parameter but that then causes setting DataContex within XAML to throw an error because the DataContext has no accessible constructors.</p>
  
  <p>Update</p>
  
  <p>I'm setting the DataContext in the other Views like so: </p>
  
  <pre><code>&lt;UserControl.DataContext&gt;
      &lt;viewModels:SummaryViewModel/&gt;
  &lt;/UserControl.DataContext&gt;
  </code></pre>
  
  <p>but doing that creates a new instance of the ViewModel, rather than using the one bound to <code>CurrentBasePageViewModel</code>. </p>