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

3 posts, 1 answers
  1. Luc Cappaert
    Luc Cappaert avatar
    7 posts
    Member since:
    Jun 2005

    Posted 08 Apr 2013 Link to this post

    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. Answer
    George
    Admin
    George avatar
    1332 posts

    Posted 11 Apr 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Luc Cappaert
    Luc Cappaert avatar
    7 posts
    Member since:
    Jun 2005

    Posted 11 Apr 2013 Link to this post

    George, thanks a lot for this answer and sample !
Back to Top