title: WPF and MVVM: bind UserControl to XAML dynamically
body: <p>seems like a trivial task: i am building a wpf application, using MVVM pattern. what i want is dynamically change part of a view, using different UserControls, dependent on user input.</p>
  
  <p>let's say, i have got 2 UserControls, one with a button, and another with a label.
  in main view i have a container for that. following XAML "works":</p>
  
  <pre><code>&lt;GroupBox Header="container" &gt;
      &lt;local:UserControlButton /&gt;
  &lt;/GroupBox&gt;
  </code></pre>
  
  <p>and a UserControl element with buttons pops up. if i change it to another one, it works too.
  question is how to feed that groupbox dynamically. if i put something like that in my model view:</p>
  
  <pre><code>private UserControl _myControl;
  public UserControl MyControl
  {
      get
      {
          return _myControl;
      }
      set
      {
          _myControl= value;
          InvokePropertyChanged("MyControl");
      }
  }
  </code></pre>
  
  <p>and change my view XAML to something like:</p>
  
  <pre><code>&lt;GroupBox Header="container" &gt;
      &lt;ItemsControl ItemsSource="{Binding MyControl}" /&gt;
  &lt;/GroupBox&gt;
  </code></pre>
  
  <p>and feed it from command with usercontrol for button or for label: nothing happens, although "MyControl" variable is set and is "invoke property changed"..</p>