在WPF中的实现和WinForm中的实现99%相似,将要实现接受拖拽释放的控件添加DragEnter事件和Drop事件,本例中控件Grid grid作为接受控件,添加事件操作如下:private void grid_Drop(object sender, DragEventArgs e){ string fileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); //获得文件名后的操作...}private void grid_DragEnter(object sender, DragEventArgs e){ if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effects = DragDropEffects.Link; //WinForm中为e.Effect = DragDropEffects.Link else e.Effects = DragDropEffects.None; //WinFrom中为e.Effect = DragDropEffects.None}
转自:http://blog.sina.com.cn/s/blog_8679e2050100w20z.html
转载于:https://www.cnblogs.com/huangli321456/p/5113735.html
相关资源:WPF中RichTextBox对文件拖拽的支持(已解决)