Create a DragVisual when dragging files into the application

2 posts, 0 answers
  1. Hiroshi
    Hiroshi avatar
    5 posts
    Member since:
    Nov 2013

    Posted 28 Mar 2014 Link to this post


    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.

  2. Administrator
    Administrator avatar
    2 posts

    Posted 04 Apr 2014 Link to this post

    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.


    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top