开发者

How to use DragDrop technique [duplicate]

开发者 https://www.devze.com 2023-04-04 03:51 出处:网络
This question already has an ans开发者_Python百科wer here: Closed 11 years ago. Possible Duplicate:
This question already has an ans开发者_Python百科wer here: Closed 11 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消