I want to make a metro user control draggable. The user should be able to drag it and drop it on other controls, causing things to happen. How do I implement this functionality?
The only method I’ve discovered that works is using the GridView and ListView controls. They have a ‘CanDragItems’ property which, when true, means any item in the view can be dragged and dropped. I tried wrapping my control in a gridview or listview but they interfere with the layout in ways I don’t understand.
I’d prefer not to emulate functionality provided by the OS. I could do it, by using the raw mouse/tap events, but it wouldn’t properly respect system settings like the size of the dead zone preventing accidental dragging.
I ended up just emulating the functionality by watching mouse events. I ask the control being dragged for a ‘doppleganger’ copy that looks the same but has no functionality, place it on the top-level grid, and adjust its render transform to move it.
However, note that if my requirements had been slightly different I might have been able to use the manipulation mode/events to do what I wanted. They’re particularly nice because they have inertia built-in, but they’re a bit pickier about focus and I didn’t manage to cross parent control boundaries with it.