Drag-Drop between RadListBox and RadScheduleView
This help topic will explain in details the drag-drop functionality between RadListBox and RadScheduleView controls.
Drag-Drop between RadListBox and RadScheduleView
To enable drag and drop between RadListBox and RadScheduleView, we should convert the data used in both controls to the corresponding type. RadListBox should have a ListBoxDragDropBehavior and a DataConverter set. The DataConverter is used to convert the dragged appointments from the ScheduleView to the ListBox. Also note that you should customize the ScheduleView DragDropBehavior in order to convert the ListBox items to ScheduleView Appointments:
We will go through a simple example to illustrate the approach. RadListBox is bound to a collection of Customer objects which will be converted to Appointments and vice versa.
- Create a Customer class:
Business object creation
- Create a ViewModel that initializes the ListBox ItemsSource and the ScheduleView AppointmentsSource and populate them with simple data:
ViewModel creation
- Create AppointmentToCustomerConverter class that inherits DataConverter:
AppointmentToCustomerConverter class creation
- Create custom ScheduleViewDragDropBehavior that inherits ScheduleViewDragDropBehavior:
ScheduleViewDragDropBehavior
- Create a RadListBoxItem Style that will enable the drag of the RadListBoxItem controls:
RadListBoxItem Style
- The final configuration of the two controls in XAML should look like:
Configuration of RadListBox and RadScheduleView
Here is the end result: