Skip to content

Advanced DragDrop functionality #18668

Open
@amwx

Description

@amwx

Is your feature request related to a problem? Please describe.

Issue sort of supercedes my previous issue (#7556) on DragDrop stuff. Avalonia's DragDrop functionality is quite bare bones.

Describe the solution you'd like

Missing Events from WPF
Implement QueryContinueDrag and GiveFeedback events that are implemented in WPF.

QueryContinueDrag is used to determine if dragging should continue based on Key states
GiveFeedback is used to give feedback to the user, specifically allowing custom dragdrop cursors

WPF does have both Tunneling and Bubbling versions of these events, but Avalonia didn't follow that with the other drag events so I think we can ignore the Preview versions of these.



Preview Drag Image & drag descriptions
In #7556, # 4 I was trying to implement a popup that showed a preview of what was dragged. It turns out that Windows can do this for you, but requires some additional infrastructure in the DragDrop stuff. IDropTargetHelper and IDropSourceHelper need to be implemented.

This also enables drag description tooltips (ex: drag a file into a folder in Explorer and there will be a little tooltip that says "Move to Folder")

Winforms did an implementation of this here. I tried to start implementing this for my own use but I got a bit lost between what they did and how Avalonia does COM stuff. I'm still playing with it but even if I get it working for Windows I don't know about the other platforms, nor do I have time to write tests to submit as a PR. Their implementation also adjusts the GiveFeedback event for updating the drag description, image, and image offset during that event. I played with this and it mostly works - it does sort of break if you drag outside the current window.

Drag UI is pretty commonplace now, there's a couple other comments on #7556 with others trying to do it, and more recently #17609. Also to note that this OLE method of doing it still doesn't replace # 4 in #7556 as we should still have a way to do it via popup / custom logic, as you can in WPF.

The WinRT apis for DragDrop also allow this with a much nicer API. I don't know if there is a plan to replace the OLE apis with WinRT (if that is even possible to do), but that would also support this.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions