This is a migrated thread and some comments may be shown as answers.

Create a DragVisual when dragging files into the application

2 Answers 16 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Hiroshi
Top achievements
Rank 1
Hiroshi asked on 28 Mar 2014, 07:19 AM
Hello,

I already implemented some drag and drop behaviors in my application. To do so, I create a DragVisual in the OnDragInitialize event (registered via DragDropManager.AddDragInitializeHandler), and I give it a DataContext (a Content actually) and a ContentTemplate. Then I can have a nice preview of the data being dragged that I can template as I wish and that will follow the mouse cursor.
This work perfectly when I'm dragging data from my app, to my app.

Now I am willing to be able to drag files, from the windows explorer, to a specific control of my application. I would like to create a DragVisual in the same way, when the mouse cursor enters one of the windows of my application (and destroy it if the mouse cursor leaves the window, but this is another problem).

The problem is that when the drag starts from another application, OnDragInitialize is not invoked (which makes perfectly sense). But how can I achieve to create a DragVisual in this context? None of the other drag'n'drop-related events have a DragVisual in their EventArgs.

Thanks

2 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 02 Apr 2014, 09:08 AM
Hi Hiroshi,

The explained scenario is a framework behavior - when the dragged item from the Windows Explorer enters the WPF application the default drag visual is changed to the default WPF one. And you won't be able to change the DragVisual in any of the methods of the DragDropManager. However you can check the approach demonstrated in this blog post, which actually will help you to achieve the required - you will need to implement the library from example and use it with our DragDropManager.

Hope this will help you to achieve the required.

Regards,
Kalin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Administrator
Telerik team
answered on 04 Apr 2014, 08:07 AM
Hi Hiroshi,

The explained scenario is a framework behavior - when the dragged item from the Windows Explorer enters the WPF application the default drag visual is changed to the default WPF one. And you won't be able to change the DragVisual in any of the methods of the DragDropManager. However you can check the approach demonstrated in this blog post, which actually will help you to achieve the required - you will need to implement the library from example and use it with our DragDropManager.

Hope this will help you to achieve the required.

Regards,
Administrator
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DragAndDrop
Asked by
Hiroshi
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Administrator
Telerik team
Share this question
or