title: Dynamically set a UserControl in a WPF app with MVVM
body: <p>I'm creating a kind of base WPF application to host WPF user controls, that will come in an assembly (later this will be AddIns). The application and the user control are following MVVM. Unfortunately I'm new to WPF and MVVM, so I am not that familiar with the specials. I have searched a lot, but nothing that helped me (or I didn't understand the solution, that might be possible).</p>
  
  <p>So my application contains basic functionality for the user controls and a window that is split into a menu bar and the placeholder for the user control. This is what I have so far, there is a button to choose the VersionControl control, which will call a function in the viewModel of my MainWindow where I load the user control, but I do not get it to be shown in the MainWindow.</p>
  
  <pre><code>&lt;Grid DataContext="{StaticResource Windows1ViewModel}"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="50" /&gt;
              &lt;RowDefinition Height="*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
      &lt;Canvas Grid.Row="0"                &gt;
          &lt;Button Content="VersionControl"
                  Style="{StaticResource ButtonStyle1}"
                  HorizontalAlignment="Center"
                  Command="{Binding LoadVersionControl}" /&gt;
      &lt;/Canvas&gt;
      &lt;Canvas Grid.Row="1"&gt;
          &lt;ItemsControl Name="ControlCanvas" /&gt;
      &lt;/Canvas&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The ViewModel definitions:</p>
  
  <pre><code>public ICommand LoadVersionControl { get { return new DelegateCommand(OnLoadVersionControl); } }
  </code></pre>
  
  <p>But what do I need to do in the OnLoadVersionControl function? I have the VersionControlView and VersionControlViewModel, but no idea how to get it shown in my application.
  Many thanks for your help,</p>
  
  <p>Mike</p>