Drag Drop inside WPF ToolWindow in VS2010 Extension not allowed

I have a strange problem here. I created a simple plug-in using the wizard for a Visual Studio / VSIX integration project using a tool window. Inside this window, I want to make a simple drag and drop from the list and drop it in the same window. I did the same in a regular WPF program, but when I do this in the WS toolwindow, this is not allowed. I start the drag operation (triggered by the event PreviewMouseLeftButtonDown) and call the method DragDrop.DoDragDrop(), I immediately get the stop sign cursor. No drag and drop allowed.

Any ideas? Security restrictions or the impact of the fact that these WPF controls are placed inside ToolWindowPane and the old Visual Studio IDE COM environment, I think ... Thanks for any help!

+3
source share
1 answer

Alin Constantin at Microsoft helped me here and even wrote a blog post on how to make the drag and drop in VS2010 right!

http://alinconstantin.blogspot.com/2010/02/drag-and-drop-in-visual-studio-2010.html


Highlights if the link rots:

In the (UserControl) tool window OnDragEnter, override OnDragOver(important!) And OnDrop. Failure to override OnDragOverwill cause the drag to fail.

In OnDragEnterfollow these steps:

  • Check if you can handle the frame
  • If so, set DragEventArgs.Handledto trueand DragEventArgs.Effectsto the appropriate value
  • Call base.OnDragEnter()

OnDragOver OnDragEnter. Handled, Visual Studio , !

OnDrop,

  • DragEventArgs.Handled true
  • base.OnDrop()

, OnDragOver , Visual Studio , OnDrop.

+5

Source: https://habr.com/ru/post/1730470/


All Articles