locked
Supporting drag/drop to open files when tool window/document is implemented in WPF RRS feed

  • Question

  • When the document well is empty, or the document well has the source code editor open, etc, I can drag/drop a file from Explorer, drop it in the document well area, and the file opens in Visual Studio.  However if I have my own document (implemented in WPF) open and I drag/drop from Explorer, it doesn't open; I have to drop on a different part of Visual Studio to open the file.

    What do I need to do in my view to support this?  Do I need to handle the drag/drop event and call Visual Studio to open the file?  Or is there a way I can let Visual Studio handle the drop?  Thanks.

    • Moved by DotNet Wang Tuesday, August 23, 2016 2:37 AM vs general forum related
    • Moved by lake Xiao Wednesday, August 24, 2016 2:50 AM
    Monday, August 22, 2016 9:42 PM

All replies

  • Hi ewells,

    According to your description, it's more related to vs general forum, we'll move the thread to vs general forum for support.

    Thanks for your understanding.

    Best regards,

    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 23, 2016 2:36 AM
  • I don't think that's true, I'm specifically asking about a scenario where I have an extension that provides a custom document or tool window where the UI is implemented in WPF.  This is definitely an extensibility question, not a general question.
    Tuesday, August 23, 2016 3:12 PM
  • Hi ewells,

    If you want to use visual studio extension to handle drag/drop event. you could override OnDragDropOnDragOver method to achieve it. For more information, please refer to:

    How to: Add a Drag-and-Drop Handler

    Best regards,

    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by DotNet Wang Wednesday, August 24, 2016 8:03 AM
    Wednesday, August 24, 2016 8:03 AM
  • Hi Li, sorry but this still doesn't answer my question.  I know that in WPF I can use OnDragDrop, OnDragOver, etc to handle drag/drop events.  What I am asking though is what if I do NOT want to handle it and I want Visual Studio to handle it instead?

    Generally when you drag a file from Explorer to the Visual Studio document well area and drop it, Visual Studio will open the file.  This does not happen by default in my WPF views.  So what I'm trying to figure out is a) is it up to my views to handle the drop and call Visual Studio to open the file, or b) is there a way to delegate the drop to Visual Studio so it will open the file?  It seems to me there should be some way to do b), surely Visual Studio doesn't make every document and tool window implementation implement a) on their own?

    Wednesday, August 24, 2016 7:25 PM