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

Drag&Drop to desktop

2 Answers 138 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Felix
Top achievements
Rank 1
Felix asked on 19 Oct 2015, 02:15 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 22 Oct 2015, 08:16 AM
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
0
Felix
Top achievements
Rank 1
answered on 22 Oct 2015, 02:17 PM

Hi Kalin,

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

 Thank you

Felix

Tags
DragAndDrop
Asked by
Felix
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Felix
Top achievements
Rank 1
Share this question
or