title: Databinding Lines, Text, etc. to ItemsControl for cad-like vector drawing on a canvas
body: <p>Using the MVVM pattern I want to write lines and text to a Canvas much like a vector CAD application would.  In researching this I have concluded that I need to use an ItemsControl with the ItemsPanelTemplate declared as a Canvas, as in</p>
  
  <pre><code>&lt;ItemsControl&gt;
     &lt;ItemsControl.ItemsPanel&gt;
        &lt;ItemsPanelTemplate&gt;
           &lt;Canvas/&gt;
        &lt;/ItemsPanelTemplate&gt;
     &lt;/ItemsControl.ItemsPanel&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>I have also figured out that I need to put <em>something</em> (not sure what) in the ItemTemplate, like so . . .</p>
  
  <pre><code>  &lt;ItemsControl.ItemTemplate&gt;
       &lt;DataTemplate&gt;
           &lt;!--  Don't know what goes here --&gt;
       &lt;/DataTemplate&gt;
    &lt;/ItemsControl.ItemTemplate&gt;
  </code></pre>
  
  <h2>My Question</h2>
  
  <p>Can someone advise me on what to put in the DataTemplate so that I can bind to my ViewModel and have the ViewModel draw either text (any rotation, any font, etc.), a line, an arc, a bezier, a shape - - - whatever I need depending on the various kinds of elements in my bound collection?</p>
  
  <p>My guess is that is should be a System.Windows.FrameworkTemplate, but I am still trying to figure out how to use it, and it is slow-going.  Or maybe ContentControl and Presenter?</p>
  
  <h2>References</h2>
  
  <p><a href="https://stackoverflow.com/questions/4708151/how-to-convert-x-y-position-to-canvas-left-top-properties-when-using-itemscontro" title="How to convert X/Y position to Canvas Left/Top properties when using ItemsControl">How to convert X/Y position to Canvas Left/Top properties when using ItemsControl</a></p>
  
  <p><a href="https://stackoverflow.com/questions/5261640/how-can-i-position-viewmodels-in-an-itemscontrol">How can I position ViewModels in an ItemsControl</a></p>
  
  <p><a href="https://stackoverflow.com/questions/889825/is-it-possible-to-bind-a-canvass-children-property-in-xaml">Is it possible to bind a Canvas's Children property in XAML?</a>
  Note: See the second answer on this one.</p>