4

Possible Duplicate:
Drag and drop to Desktop / Explorer

I have a listview which contain a file's path (Ex: D:\myfile.txt ). I want my user to be able to copy the selected item by dragging the item in the listview and drop it to my user's desire path in the Window Explorer

Community
  • 1
  • 1
HIA YongKuy
  • 119
  • 1
  • 3

1 Answers1

1

I am not sure about doing this from WPF but from windows forms used to work more or less like this:

private void listView1_ItemDrag(object sender, 
        System.Windows.Forms.ItemDragEventArgs e)
{
    string[] files = GetSelection();
    if(files != null)
    {
        DoDragDrop(new DataObject(DataFormats.FileDrop, files), 
                   DragDropEffects.Copy | 
                   DragDropEffects.Move);
    }
}

the important thing is to specify DataFormats.FileDrop and initiate the DoDragDrop... with some changes I guess you should get it working from WPF

Davide Piras
  • 43,984
  • 10
  • 98
  • 147