In this post I will demonstrate how to extend the Drag Drop functionality of the RadDragAndDropManager adding command support by using the attached behaviors extensibility. That way one can easily move the logic for the operation from the code behind into your model and work only with the Data object. To demonstrate the idea I will use scenario where items are being dragged between ListBoxes.
The behavior transforms the Drag Drop events into commands. It exposes the following properties:
- DragCommand – executed when dragInfo event is raised.
- DropCommand – executed when dropInfo event is raised.
- DragCueTemplate – data template that defines the dragcue appearance.
The command parameter being transferred to the commands contains the data describing the drag status. In order to handle more specific cases we can transmit additional information to the viewmodel by adding additional properties:
If you like this functionality you can check the attached project demonstrating this in action
Download Source SL4
Download Source WPF
Tsvyatko Konov is software developer in Telerik Windows 8 product team. You can follow him on Twitter @tsvyatco and his personal blog at www.konov.me