0

I have a control with a List Box containing some appointments that can be drag drop over a RadScheduleView. This is working fine but i want to copy (not move) the appointment. If it is possible I want to handle the creation of the new appointment because i'm inheriting from Appointment and added a new property to the class.

I know that drag copy can be done using Ctrl key while dragging but i want to make copy the default behavior.

Maybe forcing the Ctrl key to be pressed when the user clicks on the List Box Item could work. I don't know how to do the last but anyway doesn't seems to be the best approach.

this is a sketch of the control. drag drop from list box to schedule view should copy. drag drop between schedule view should move. control with list box and schedule view

If someone needs more details, please comment and I'll edit. thanks.

rareyesdev
  • 2,337
  • 1
  • 25
  • 43

1 Answers1

2

After a lot of research i found how to make copy by default. I'm answering my own question so people can use it.

The class in charge of the DragDrop source (the ListBox) is Telerik.Windows.DragDrop.Behaviors.ListBoxDragDropBehavior. We just need to implement our own class that inherits from Telerik.Windows.DragDrop.Behaviors.ListBoxDragDropBehavior and use it in the xaml when creating the ListBox like this:

<ListBox>
    <drag:ListBoxDragDrop.Behavior>
        <loc:ListBoxDragDropBehavior/>
    </drag:ListBoxDragDrop.Behavior>
</ListBox>

We only have to change IsMovingItems to get the copy behavior by default.

class ListBoxDragDropBehavior :    Telerik.Windows.DragDrop.Behaviors.ListBoxDragDropBehavior
{
    protected override bool IsMovingItems(DragDropState state)
    {
        return false;
    }
}

That's all. Hope it helps.

rareyesdev
  • 2,337
  • 1
  • 25
  • 43