punker76 / gong-wpf-dragdrop

The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
BSD 3-Clause "New" or "Revised" License
2.25k stars 392 forks source link

Touch and hold drag to support touch scrolling #459

Closed khdc closed 1 year ago

khdc commented 1 year ago

What changed?

This fixes #360.

I am building a commercial app that is 100% touch, so this feature is critical for me. I hope it will help others. This is my first PR here, so I appreciate your patience and understanding.

To simultaneously support touch drag and scrolling in a scrollable ItemsControl, I updated DragDrop.cs with a touch and hold gesture that will trigger a drag operation after configurable number of milliseconds.

When the user places their finger down, holds, and the timer ticks, it will display an animated adorner under their finger giving them a visual indicator that they can drag the item.

When the touch drag starts, the system sets the ScrollViewer.PanningMode="None" to prevent touch scrolling. The system will remember the previous setting and restore it once the drag is complete.

I added two attached properties to the DragDrop.Properties.cs file to support setting the background color of the touch and hold adorner as well as the touch and hold delay. The default delay is 600 milliseconds.

For the best touch user experience in a scrollable ItemsControl, the following properties should be set on the ItemsControl:

khdc commented 1 year ago

It looks like this needs more work. It's not working reliably in my application. I will continue to work on it.

punker76 commented 1 year ago

@khdc Are you still working on this feature? Even if you have closed this PR?

khdc commented 1 year ago

@punker76 yes! I plan on submitting a new PR once I figure out a few remaining issues and clean up the code.

khdc commented 1 year ago

@punker76 I need a consistent way to handle the PreviewTouchUp event independent of where the drag is initiated. Do you have a preferred way that I do that?