Drag&Drop to desktop

3 posts, 1 answers
  1. Felix
    Felix avatar
    2 posts
    Member since:
    Feb 2012

    Posted 19 Oct 2015 Link to this post

    We are implementing a drag&drop scenario, where the drop target can be another control from our application or the drop target can be the desktop or another folder from the file system. How can I set the dragged data inside the DragInitializeHandler to handle both scenarios simultaneously?

    If the dragged data is a DataObject where the data is set via SetFileDropList I can drag the data to the desktop but not to another control. If I create a IPayload and sets the data via SetData("DragData", ...) and SetData("FileDrop", ...) I can drag the data to the other control but not to the desktop?

    How can I create a payload, which is working for both scenarios? 

    Felix

  2. Answer
    Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 22 Oct 2015 Link to this post

    Hi Felix,

    You should be able to add more data to the DataObject used for dropping on the desktop and used for dropping on other WPF controls as well. Check the following code snippet:

    var stringCollection = new StringCollection();
    var listBox = sender as RadListBox;
     
    foreach (Item item in listBox.SelectedItems)
    {
        stringCollection.Add(item.Name);
    }
    var data = new DataObject();
    data.SetFileDropList(stringCollection);
    data.SetData("DraggedData", listBox.SelectedItem);
    e.Data = data;

    Afterwards when a drop is received on WPF control you would be able to extract the DraggedData object using the following snippet:
    var dragedData = (e.Data as DataObject).GetData("DraggedData") as Item;

    Please let me know if this helped. If not I would like to ask you to share sample project demonstrating the exact scenario, so we can check it on our side.

    Regards,
    Kalin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Felix
    Felix avatar
    2 posts
    Member since:
    Feb 2012

    Posted 22 Oct 2015 in reply to Kalin Link to this post

    Hi Kalin,

     thank you very much for this sample. Now it is working perfect.

     Thank you

    Felix

Back to Top