title: Binding to a collection of shapes?
body: <p>How would I bind to a collection of shapes?</p>
  
  <p>I'd like to build a small application (just for learning purposes) where I utilize MVVM for drawing shapes. </p>
  
  <p>The DataContext of the MainWindow is the MainWindowViewModel </p>
  
  <p>That MainWindowViewModel has an ObservableCollection of shapes. </p>
  
  <p>I have currently only a Canvas on my MainWindow with its DataContext bound to that collection which does not work:</p>
  
  <pre><code>&lt;Window x:Class="DesktopCanvas.MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  &gt;
      &lt;Canvas DataContext="{Binding Source=ShapeCollection}"&gt;
      &lt;/Canvas&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>In the constructor of the MainWindowViewModel I add a rectangle like this:</p>
  
  <pre><code>this.ShapeCollection = new ObservableCollection&lt;Shape&gt;();
  Rectangle rect = new Rectangle();
  //Größe
  rect.Height = 75;
  rect.Width = 75;
  //Transparenz
  rect.Opacity = 100;
  //Farbe
  SolidColorBrush myBrush = new SolidColorBrush(Colors.Red);
  rect.Fill = myBrush;
  this.ShapeCollection.Add(rect);
  </code></pre>
  
  <p>No Binding errors so far. Any ideas? </p>