Drag and Drop with RadListBox
With our Q1 2013 release of RadGanttView control we have introduced a new built-in feature in the control that allows drag and drop functionality between the GanttView control and an outside source.
This help article demonstrates how to achieve drag and drop between RadListBox and RadGanttView controls.
Before proceeding with this help article you should get familiar with RadListBox: Binding To Object, RadListBox: Drag and Drop Overview and RadGanttView: Implementing View-ViewModel.
-
First you will need to declare the RadListBox control in the xaml and populate it with some sample data:
and the ViewModel should look like this:
-
Next you should declare the RadGanttView control in the xaml and populate it with some sample data:
and the ViewModel should look like this:
-
Create a custom GanttDragDropBehavior and override its CanStartDrag() method in order to restrict the drag and drop functionality from the Timeline of the GanttView control (in the current version of the control drag and drop from the Timeline is not supported):
-
Create a custom DataConverter that will convert the drag data from the GanttView to the ListBox control:
-
Create a custom DataConverter for that will convert data from ListBox to the GanttView control:
-
Declare the newly created GanttDragDropBehavior and converters to the ListBox and GanttView controls, the xaml of the two controls should look like this:
The next screenshots show the final result: