title: Listbox Drag and drop issue in WPF with touch
body: <p>I have a WPF app which contains a listbox and a few items. In between I have also added dummy items so that I can drag and drop between these items.</p>
  
  <p>I have implemented the drag and drop and it works perfectly with the mouse. With touch it works, but not the way I desire it to. When listbox items is not selected, a drag and drop using touch works but without any drag and drop effect, I guess I will have to create an <code>Adorner</code> for that. But when a listbox item is selected, the drag and drop doesn't work. I have to manually unselect the item and then it works. Even the <code>UnSelectAll()</code> method does no good.</p>
  
  <p>I just wanted to know how exactly should drag and drop be implemented for touch devices?</p>
  
  <p>The code snippets are as follows:</p>
  
  <pre><code>private void s_PreviewMouseDown(object sender, MouseButtonEventArgs e)
  {
      if (sender is ListBoxItem)
      {
          ListBoxItem draggedItem = sender as ListBoxItem;
          System.Windows.DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Move);
          draggedItem.IsSelected = true;
      }
  }
  private void s_PreviewTouchDown(object sender, TouchEventArgs e)
  {
      if (sender is ListBoxItem)
      {
          ListBoxItem draggedItem = sender as ListBoxItem;
          System.Windows.DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Move);
          draggedItem.IsSelected = true;
          e.Handled = true;
      }
  }
  private void listbox1_Drop(object sender, DragEventArgs e)
  {
      ItemTemplate droppedData = e.Data.GetData(typeof(ItemTemplate)) as ItemTemplate;
      ItemTemplate target = ((ListBoxItem)(sender)).DataContext as ItemTemplate;
  
      int removedIdx = listBox1.Items.IndexOf(droppedData);
      int targetIdx = listBox1.Items.IndexOf(target);
  
      Swap&lt;ItemTemplate&gt;(AppsList, targetIdx, removedIdx);
  }
  </code></pre>
  
  <p>Any help would be appreciated. Is the <code>Listbox</code> in WPF having issues with touch?</p>