title: ItemsControl Drag and Drop
body: <p>I have an ItemsControl with a DataTemplate that is bound to an ObservableCollection of integers.</p>
  
  <pre><code>&lt;ItemsControl Name="DimsContainer" ItemTemplate="{StaticResource DimensionsTemplate}"&gt;
      &lt;ItemsControl.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;StackPanel Orientation="Horizontal"/&gt;
          &lt;/ItemsPanelTemplate&gt;
     &lt;/ItemsControl.ItemsPanel&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>And in the Windows Resources:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;DataTemplate x:Key="DimensionsTemplate" &gt;
          &lt;TextBlock Text="{Binding}"
                         Padding="5"
                         VerticalAlignment="Center"
                         FontSize="32"/&gt;
      &lt;/DataTemplate&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>I'm trying to implement the ability to drag and drop items within the ItemsControl (i.e. to be able to reorder the integers). Does anyone have a simple example of how to do this? I hooked up the PreviewMouseMove, DragEnter and Drop events. The problem is that I can't figure out how to determine which item is being dragged and where it is dragged to. It seems that the entire ItemsControl gets passed into the events.</p>