Closed mhmd-azeez closed 7 years ago
@encrypt0r You can implement the IDropTarget
interface on your view or view model and handle this.
public void DragOver(IDropInfo dropInfo)
{
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
var dataObject = dropInfo.Data as IDataObject;
// look for drag&drop new files
if (dataObject != null && dataObject.GetDataPresent(DataFormats.FileDrop))
{
dropInfo.Effects = DragDropEffects.Copy;
}
else
{
dropInfo.Effects = DragDropEffects.Move;
}
}
public void Drop(IDropInfo dropInfo)
{
var dataObject = dropInfo.Data as DataObject;
// look for drag&drop new files
if (dataObject != null && dataObject.ContainsFileDropList())
{
this.HandleDropActionAsync(dropInfo, dataObject.GetFileDropList());
}
else
{
GongSolutions.Wpf.DragDrop.DragDrop.DefaultDropHandler.Drop(dropInfo);
var data = dropInfo.Data;
// do something with the data
}
}
I need to drag and drop files from Windows Explorer into my main window. Which works fine. But the drag adorners don't work. It just shows the standard windows cursors. I tried it on the sample app too, doesn't work there either.