14

How do we add drag & drop functionality in Xamarin..

After lot of googling I found the following official link for drag & drop for xamarin..

https://blog.xamarin.com/android-tricks-supporting-drag-and-drop-in-an-app/

But it uses the android native code only.

My questions:

  1. In Xamarin is it possible to implement drag & drop functionality without native codes?

  2. If answer - No -> How do we achieve the drag & drop listeners for all platforms?

I searched google & the official forum and nothing found.. Someone help me..Thanks..

Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159

3 Answers3

1

Xamarin.Forms does not appear to support that kind of touch. Event handlers for on touch would have to be written in the native implementations with a dependency injection pattern for accessing them from the shared code.

The only built in gestures recognized are tap, pinch and pan.

Using the below link it should not be too difficult to get drag and drop up and running.

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/touch/

https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/

ClintL
  • 1,424
  • 14
  • 30
  • Clint Landry could you give sample code for drag & drop demo.. I added bounty worth 100 reputation.. If you update the sample code I will give the bounty to you & accept your answer.. – Ranjithkumar Sep 01 '16 at 07:04
  • I was able to achieve drag & drop functionality between a pair of lists through Xamarin.Forms and the Pan gesture. However I took advantage of [Mr. Gestures](http://www.mrgestures.com/) to make my life easier with touch down events. I am happy to write up how I did it with some sample code if you are ok with using the Mr. Gestures library. – Jacob Shanley Sep 01 '16 at 19:53
  • I will but it may be a little bit, publishes this week. – ClintL Sep 01 '16 at 20:40
  • ok.. no problem..bounty end in 6 days.. so please answer before bounty time end.. – Ranjithkumar Sep 02 '16 at 04:09
  • @JacobShanley could you provide your solution? I'm interested in using MR Gestures for this purpose. – iupchris10 Jan 18 '17 at 16:17
1

2020 it looks like we have it. You still need to set up DragAndDrop_Experimental flag.

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/drag-and-drop

valentasm
  • 2,137
  • 23
  • 24