title: WPF - DragOver event is not firing on my Listbox
body: <p>I am trying to implement drag and drop functionality in my WPF application. I have a Listbox that I would like to be able to drop files on from Windows Explorer. These files would then be added to the listbox. I had this working at one time, following this tutorial: <a href="http://www.strathweb.com/2012/06/drag-and-drop-files-to-wpf-application-and-asynchronously-upload-to-asp-net-web-api/." rel="nofollow">Drag and drop files to WPF application and asynchronously upload to ASP.NET Web API</a>. Minus the upload to web api part. I just want to show the files in my listbox.</p>
  
  <p>The problem is that the DragOver event never fires. What am I missing? I had this working earlier, but some small tweak messed it up.</p>
  
  <p>Here is my XAML (simplified the parent elements):</p>
  
  <pre><code>&lt;Window&gt;
    &lt;Grid&gt;
      &lt;TabControl&gt;
        &lt;TabItem&gt;
          &lt;Grid&gt;
            &lt;GroupBox&gt;
              &lt;ListBox Name="lstTarget" AllowDrop="True"
                       Drop="lstTarget_Drop"
                       DragOver="lstTarget_DragOver"
                       DragLeave="lstTarget_DragLeave"
                       BorderThickness="3"
                       BorderBrush="Red"
                       &gt;
              &lt;/ListBox&gt;
  </code></pre>
  
  <p>Here is my code behind</p>
  
  <pre><code>private void lstTarget_Drop(object sender, DragEventArgs e)
  {
      if (e.Data.GetDataPresent(DataFormats.FileDrop))
      {
          string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
          foreach (string filePath in files)
          {
              lstTarget.Items.Add(filePath);
          }
      }
  
      var listbox = sender as ListBox;
      listbox.Background = new SolidColorBrush(Color.FromRgb(226, 226, 226));
  }
  private void lstTarget_DragOver(object sender, DragEventArgs e)
  {
      lstTarget.BorderBrush = Brushes.Green;
  
      if (e.Data.GetDataPresent(DataFormats.FileDrop))
      {
          e.Effects = DragDropEffects.Copy;
          var listbox = sender as ListBox;
          listbox.Background = new SolidColorBrush(Color.FromRgb(155, 155, 155)           
      }
      else
      {
          e.Effects = DragDropEffects.None;
      }
  }
  
  private void lstTarget_DragLeave(object sender, DragEventArgs e)
  {
      var listbox = sender as ListBox;
      listbox.Background = new SolidColorBrush(Color.FromRgb(226, 226, 226));
  }
  </code></pre>