private void Target_Drop(object s, DragEventArgs e) { if (IsInitialized()) { if (IsDragging) { e.Handled = true; if (e.Data.GetDataPresent(Name)) { DropEventArgs ea = new DropEventArgs() { Package = e.Data.GetData(Name), Source = currentSource }; // Invoke the CanDrop event again to ask the target if we're allowed to drop CanDrop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea); if (ea.AllowDrop) { Drop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea); // Also fire DragLeave since the system won't do this for us. DragLeave.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(); } } } } }
private void Target_DragLeave(object s, DragEventArgs e) { if (IsInitialized()) { if (IsDragging) { e.Handled = true; DropEventArgs ea = new DropEventArgs() { Package = e.Data.GetData(Name), Source = currentSource }; CanDrop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea); if (ea.AllowDrop) { DragLeave.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(); } } } }