-1

I have old WinForms application with DragDrop functionality (without any source code). Now I need to create new WPF application which can receive some data from old one with DragDrop. But DragDrop isn't working in WPF app and any events: DragEnter, DragOver, DragLeave, Drop doesn't fire. I've created other simple WinForms application only with DragDrop functionality and it's working OK. Also, I can do DragDrop from this simple WinForms app to WPF app.

I've tried to run my apps "As Administrator" and without this - nothing changed.
Does anybody know, how to fix this or what is root cause or can be the root cause of such strange behavior?

Artur Korop
  • 1
  • 1
  • 1

2 Answers2

0
  • Have you set the (AllowDrop="true") in wpf xaml?
  • and if that was yes, do you handle the Drop event for the capturing form or control?

see this question on stackoverflow.com for more details: WPF Drag and Drop

Community
  • 1
  • 1
Mazen el Senih
  • 101
  • 1
  • 4
  • Yes, of course. As I said, I have 3 applications: old one with Drag functionality, new WPF with Drop functionality and test WinForms with DragAndDrop functionality. And works only: Old -> test WinForms, Test WinForms -> WPF, but my goal - Old -> WPF. – Artur Korop Mar 16 '17 at 05:48
  • Also, I've tried to use RegisterDragDrop from ole32 library, but it has returned error code. – Artur Korop Mar 16 '17 at 05:52
  • @ArturKorop I'm not that familiar with WPF, but the same principle applies from C# WinForms. sometimes you have to explicitly handle the same exact type from FileFormat. – Mazen el Senih Mar 16 '17 at 13:20
0

Ok, I was able to solve the issue. The reason - the old app use RegisterDragDrop for OleDataFormat, but new WPF - use RegisterDragDrop for DataFormat. The solution - set AllowDrop to false, and use RegisterDragDrop from ole32.dll for OleDataFormat with custom IDropTarget interface or from WinForms library.

Artur Korop
  • 1
  • 1
  • 1