I am performing a drag drop between WPF ListBoxes and I would like to be able to insert into the collection at the position it is dropped rather than the end of the list.
Does anyone know of a solution that is similar to the WinForms ListBox IndexFromPoint function?
I ended up getting this work by using a combination of DragDropEvent.GetPosition, VisualTreeHelper.GetDescendantBounds and Rect.Contains. Here’s what I came up with:
The code resides in the ListBox Drop event. The e object is the DragEventArgs object passed into the Drop event.
The implementation for IsMouseOverTarget is: