title: Rebuild statusbar on the fly with databinding
body: <p>Im building a plugin system where each plugin has its own statusbar, containing different regions. So Plugin #1 could have a statusbar with 2 x 200 pixels regions, while Plugin #2 can have just a single 400 pixel region.</p>
  
  <p>Im building this in <code>WPF/MVVM</code> and in my viewmodel for the application, the <code>StatusBar</code> for the plugin gets loaded when i switch between plugins.</p>
  
  <p>I have a observablecollection of statusbars that i load to:</p>
  
  <pre><code>ObservableCollection&lt;StatusBar&gt; StatusBars 
  { 
      get;
      set;
  }
  </code></pre>
  
  <p>And then i have a function just retrieves the collection of statusbars for that plugin.</p>
  
  <p>The class that gets loaded looks something like this:</p>
  
  <pre><code>public class StatusBar : ObservableObject
  {
      public string Name { get; set; }
      public int Width { get; set; }
      public StatusBarAreaType Type { get; set; }
  
      string _message;
  
      public string Message
      {
          get
          {
              return _message;
          }
  
          set
          {
              if (_message != value)
              {
                  _message = value;
                  OnPropertyChanged();
              }
          }
      }
  }
  </code></pre>
  
  <p>My problem is that i cant get the XAML to support me loading the collection and showing each <code>StatusBar</code> as its own region. A simplified version of how i tried going about this looks something like this:</p>
  
  <pre><code>&lt;StatusBar VerticalAlignment="Bottom" Height="25" ItemsSource="{Binding StatusBars}" ItemTemplate="{DynamicResource StatusBarTemplate}"&gt;
      &lt;StatusBar.Resources&gt;
          &lt;DataTemplate x:Key="StatusBarTemplate"&gt;
              &lt;TextBlock Text="{Binding Message}"&gt;&lt;/TextBlock&gt;
          &lt;/DataTemplate&gt;
      &lt;/StatusBar.Resources&gt;
  &lt;/StatusBar&gt;
  </code></pre>
  
  <p>(I have tried <code>StatusBarItem</code> stuff, <code>ItemsControl</code> templates, using a grid inside instead etc etc)</p>
  
  <p>How do i achieve my goal of having a <code>StatusBar</code> consisting of different regions based on the StatusBar class?</p>