This is a migrated thread and some comments may be shown as answers.

Moving an item within the list using DragDropService

1 Answer 184 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 17 Dec 2019, 02:37 PM

Hello,

Could you please help me with the following?

I have a listview containing multiple items, the listviewcontains SimpleListViewVisualItems.

Now I want to move items using DragDropService USING A TOUCHSCREEN (Gesture).

The functionality is working when I drag/drop using a mouse, within the list.

The functionality is working when I drag/drop using touchscreen to a second list, but when I am do drag/drop within the same list (using touchscreen), the PreviewDragOver and PreviewDragDrop events are not fired.

In my CustomRadListView, on the OnPanGesture-event I do call the dragDropService.DoMouseMove(mousep)

 

Best regards

Patrick Vossen

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Dec 2019, 10:15 AM
 

Hello, Patrick,     

According to the provided information, it is not clear how exactly you achieve the drag and drop behavior in RadListView.

RadListView's drag and drop functionality should be handled differently when using gestures. You can override the RadListView.OnPanGesture method and start the service when necessary.

    public class CustomListView : RadListView
    {
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadListView).FullName;
            }
        }

        protected override void OnPanGesture(PanGestureEventArgs args)
        {
            base.OnPanGesture(args);
            if (this.AllowDragDrop)
            {
                RadDragDropService dragDropService = this.ListViewElement.DragDropService;
                if (args.IsBegin)
                {
                    BaseListViewVisualItem visualItem = this.ElementTree != null ? this.ElementTree.GetElementAtPoint(args.Location) as BaseListViewVisualItem : null;
                    dragDropService.BeginDrag(this.ElementTree.Control.PointToScreen(args.Location), visualItem);
                }
                if (dragDropService.State == RadServiceState.Working)
                {
                    dragDropService.DoMouseMove(this.ElementTree.Control.PointToScreen(args.Location));
                }

                if (args.IsEnd)
                {
                    dragDropService.EndDrag();
                }

                args.Handled = true;
            }
        }
    }

Then, the respective events that the ListViewElement.DragDropService offers will get fired and you can handle the drag and drop operation as it is demonstrated in the following help article: https://docs.telerik.com/devtools/winforms/controls/listview/drag-and-drop/drag-and-drop-in-bound-mode

I have attached my sample project for your reference which result is illustrated in the attached gif file.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or