title: How to access the Parent of the Source in a Drop Event?
body: <p>I am trying to handle some drag and drop functionality for values in my TreeView.
  I am specifically targeting the Drop method. I want to be able to access the Parent object of the element being dragged.</p>
  
  <p>The</p>
  
  <pre><code>TreeView.SelectedItem
  </code></pre>
  
  <p>is the property of the TreeView that I suspect I will need. However, this property is of type string, so accessing the Parent object is proposing a challenge.</p>
  
  <p>I tried using the </p>
  
  <pre><code>VisualTreeHelper.GetParent(DependencyObject)
  </code></pre>
  
  <p>method but there doesn't seem to exist a conversion from string to DependencyObject and vice versa. </p>
  
  <p>I am able to access the ParentControl of the target, but not the source and I can't understand why.</p>
  
  <p>This is my Drop Method, as well as the MouseMove. Any help would be appreciated.</p>
  
  <pre><code> private void TreeViewItem_Drop(object sender, DragEventArgs e)
      {
          if (sender is TreeViewItem target)
          {
              string source = e.Data.GetData(typeof(string)) as string;
              string dropTarget = target.DataContext as string;
              var parentControl = VisualTreeHelper.GetParent((TreeViewItem)(sender));
              var parentElement = ((VirtualizingStackPanel)(parentControl)).DataContext;
  
              if (parentElement is GroupDecision decision)
              {
                  if (decision.Decisions.Contains(source) &amp;&amp; (decision.Decisions.Contains(dropTarget)))
                  {
                      int sourceIndex = decision.Decisions.IndexOf(source);
                      int targetIndex = decision.Decisions.IndexOf(dropTarget);
                      SwapElements(sourceIndex, targetIndex, decision.Decisions);
                  }
                  else
                  {
                      if (!decision.Decisions.Contains(source))
                      {
                          decision.Decisions.Add(source);
                          // Remove from old
  
                      }
                  }
              }
          }
  
  
  
   private void TreeViewItem_MouseMove(object sender, MouseEventArgs e)
      {
          if (e.LeftButton == MouseButtonState.Pressed)
          {
              if (TreeView.SelectedItem != null)
              {
                  DragDrop.DoDragDrop(this, TreeView.SelectedItem, DragDropEffects.Move);
              }
          }
      }
  </code></pre>