How does WPF implement drag-and-drop to open a file (drag the file into the form), and wpf drag-and-drop
The implementation in WPF is similar to the implementation in WinForm 99%. The DragEnter event and Drop event will be added to the control that accepts the drag and Drop release. In this example, the control Grid grid is used as the acceptance control. The operation for adding events is as follows:
Private
Void grid_Drop (object sender, DragEventArgs e)
{
String
FileName =
(System. Array) e. Data. GetData (DataFormats. FileDrop). GetValue (0). ToString ();
// Get the operation after the file name...
}
Private
Void grid_DragEnter (object sender, DragEventArgs e)
{
If
(E. Data. GetDataPresent (DataFormats. FileDrop ))
E. Effects =
DragDropEffects. Link;
// E. Effect = in WinForm
DragDropEffects. Link
Else e. Effects =
DragDropEffects. None;
// In WinFrom, e. Effect =
DragDropEffects. None
}