I want to implement drag & drop for a extended-selection-mode WPF ListBox
. So far, everything is working fine:
- I can initiate a drag operation for the selected items
- I can handle the drop operation on the target
I basically implemented it as written here - in short:
- Handle
PreviewMouseLeftButtonDown
to store current mouse position - Handle
MouseMove
to initiate the drag operation if distance has been covered
Now my problem is: Usually, in the Explorer for example, I'd select the items I want to drag, then I release the mouse button and press it again to initiate the drag & drop operation. I guess that's how most users would do it. When I do the same thing in my application now, the selection changes to the item I press the mouse button on for the second time - the multi-selection is gone.
I googled a lot yesterday, but all the solutions I could find initiated the drag operation in PreviewMouseLeftButtonDown
. That, however, does not allow me to check whether the mouse has been moved far enough to actually initiate a drag operation.
My question: Does anyone have a simple solution (not involving any third-party libraries) how I can change the sample linked above so that the multi-selection stays intact?