开发者

How to use DragDrop technique [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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜