views:

37

answers:

1

I am implementing a DragDrop framework for WPF (which incidentally you can find here).

I have a problem in that when the user MouseDowns on an ItemsControl we don't know immediately if they intended to click the item to select it, or to begin a drag. If the user clicks an item and then quickly moves the cursor, another item other than the clicked item can become selected before we determine that a drag has started (especially if clicking on the item freezes the UI for a short time to load data etc).

I think this problem didn't exist in WinForms as dragging the mouse with the button held down didn't cause another item to become selected - the selection was made only on the item on which the click occurred.

In the PreviewMouseDown event I can set the e.Handled property to prevent another item becoming selected, which works fine if the user actually did intend to start a drag, but then they can't actually select the item.

Anyone know how to handle this?

A: 

Store/use the point at which they originally moused-down, and use that to resolve the item to drag.

HTH,
Kent

Kent Boogaart
I was doing that, but then the item being dragged doesn't match up with the item selected in the ItemsControls. Confusing for the user: which item are they actually dragging?
Groky