How to use DragDrop technique [duplicate]
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
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
精彩评论