问题
I have to develop a cross platform app in Xamarin forms and its one of the requirements is to be able to drag and drop dynamically generated labels between different views on same UI (i.e. check the image).. I have generated the dynamic labels but I am not sure how to implement drag and drop functionality. Can anyone guide me regarding the best choice of controls here like the containers containing the labels? Also do I need to write separate code for implementing the drag and drop on Android and IoS? I will really appreciate if some one can point out the right resource. I have googled but there is not any useful tutorial. Some of the tutorials like this ListView DragDropSort are suggesting writing separate code for Android and IoS platforms.
回答1:
I would give you several suggestions:
You can use Mr.gestures to achieve DragAndDrop in xamarin.forms.
Check the sample here: GestureSample, it can easily drag controls, you can also check the discussion in this thread.
Take a look at this blog, use a
Draggable view in Xamarin Forms
.Sample here: DragViewSample
Here is an android native implementation example of dragging images: drag-one-image-at-a-time-to-the-top-of-another-image
Sample here :DragableView_Demo
来源:https://stackoverflow.com/questions/57187414/drag-and-drop-labels-in-xamarin-forms-app