title: Dragging and Dropping in WPF
body: <p>I've got a <code>TreeView</code> and <code>Canvas</code> in my WPF application.  I'm trying to implement functionality whereby users can drag a TreeViewItem and a method should be called when the user drops on the canvas, passing the TreeViewItem header as a parameter to this method.</p>
  
  <p>This is what I've done so far:</p>
  
  <pre><code>private void TreeViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  {
       if (e.Source.GetType().Name.Equals("TreeViewItem"))
       {
           TreeViewItem item = (TreeViewItem)e.Source;
  
           if (item != null)
           {
                DataObject dataObject = new DataObject();
                dataObject.SetData(DataFormats.StringFormat, item.Header.ToString());
                DragDrop.DoDragDrop(item, dataObject, DragDropEffects.Copy);
           }
       }
   }
  </code></pre>
  
  <p>When I drag and drop to the canvas nothing happens.  I am thus unsure of what I should do next.  I feel that it's something really small, but I'm at a loss.  How can I call the method and detect that the header has been dropped?</p>
  
  <p>Any ideas?</p>