This is a migrated thread and some comments may be shown as answers.

RadListBox - PreviewDrop - how to get the datacontext of the item being dropped ?

2 Answers 162 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Luc Cappaert
Top achievements
Rank 2
Luc Cappaert asked on 08 Apr 2013, 11:21 AM
I am using 2 listboxes with drag and drop enabled, 1 being the "source" and one being the "destination".
I need to manipulate the items in the "destination" RadListBox when a user drops an item from the "source" listbox; after a certain validation.

I wired the "PreviewDrop" event; but fail to see how I can get the datacontext of the element that is being dropped by the user.
(I worked through the properties of the DragEventArgs parameter; but couldn't find the datacontext of the item that is being dropped)

Does anyone know how to determine which item the user is dropping on my "destination" RadListBox ?

2 Answers, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 11 Apr 2013, 08:25 AM
Hello Luc,

I would suggest using a custom DragDropBehavior for the destination RadListBox control:

  • Inherit the ListBoxDragDropBehavior
  • Override the Drop method. The DragDropState object gives you information about the destination itemssource, draggeditems, insert index and etc. Here you could add some custom logic.
  • Set the CustomDragDropBehavior to the destination RadListBox.

You can find the attached sample as well. Hope this helps.


Regards,
George
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Luc Cappaert
Top achievements
Rank 2
answered on 11 Apr 2013, 08:45 AM
George, thanks a lot for this answer and sample !
Tags
ListBox
Asked by
Luc Cappaert
Top achievements
Rank 2
Answers by
George
Telerik team
Luc Cappaert
Top achievements
Rank 2
Share this question
or