RSS
 

Archive for the ‘WPF’ Category

Drag and Drop of files in WPF

10 Jan

Dragging and Dropping files in a WPF application isn’t hard. The only thing you need to do is to set the AllowDrop property to true for the whole window. Add a window drop event and everything is set… except when you’re adding extra controls like a textbox for instance. When you’re dropping files to a textbox, the drag and drop won’t work. In order to make it work you need to set the following on your textbox.


public void OnDragOver(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.All;
e.Handled = true;
}

That should do the trick!

 
No Comments

Posted in WPF