Moving an item within the list using DragDropService

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    43 posts
    Member since:
    Aug 2018

    Posted 17 Dec 2019 Link to this post

    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

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4131 posts

    Posted 18 Dec 2019 Link to this post

     

    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.
Back to Top