ListBoxDragDropBehavior: bug or error in the documentation?

1 Answer 27 Views
DragAndDrop ListBox
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 04 Feb 2022, 09:58 AM

Hello,

In the ListBoxDragDropBehavior documentation, it is said:
The ListBoxDragDropBehavior supports copying the dragged items if the Control key is pressed. For that purpose the CopyDraggedItems method should be overridden

But the behavior supports copying the dragged items without changing anything!

This is a problem because, in my case, I need to avoid the copying of the dragged items in all cases.
How can I do it?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 08 Feb 2022, 02:24 PM

Hello Patrick,

Indeed, the documentation is not matching what the behavior is doing. Actually, this statement is correct, but incomplete. The behavior supports copying the dragged items in all cases when you drag with Ctrl between different ListBox instances. The documentation matches only the case when you drag with the Ctrl inside the same ListBox instance. Only in this case you need to override the CopyDraggedItems method.

In other words, the CopyDraggedItems() method is used only when you drop items inside the same ListBox instance that started the drag operation. 

We are going the update the article. Also, you can find your Telerik points updated as a small token of gratitude for bringing this to our attention.

In the meantime, if you want to avoid copying items between the different ListBox instances, you can override one of the other methods of the DragDropBehaviorclass (inherited by ListBoxDragDropBehavior). For example, you can try IsMovingItems() which determines if the dropped items should be removed from the drag source (the ListBox that started the drag operation). If the method returns true, the dragged items will be removed, otherwise, they will be kept in the drag source (ListBox). Other methods that you can try are the Drop and DragDropCompleted.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DragAndDrop ListBox
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or