简体   繁体   English

WPF UserControl拖放

[英]WPF UserControl Drag and Drop

I'm developing an extension for MS Visual Studio using WPF and I want to perform the drag and drop operation. 我正在开发使用WPF的MS Visual Studio扩展,我想执行拖放操作。 Now, I did it in a small WPF app to see if it is working and succeed, however when I did it in my extension, I cannot perform the action. 现在,我在一个小型WPF应用程序中执行了该操作,以查看其是否正常运行,但是当我在扩展程序中执行该操作时,我将无法执行该操作。 Looks like the drop operation is not allowed. 似乎不允许执行放置操作。 When I tried GradOver/ DragEnter - everything works, however it is not good because those functions make many copies of what I would like to drag. 当我尝试GradOver / DragEnter时-一切正常,但是效果不好,因为那些功能复制了我想要拖动的内容。 What could be a problem in your opinion? 您认为可能有什么问题?

PS All Visual Studio extensions WPF controls inherent UserControl and not from Window as a regular WPF app. PS所有Visual Studio扩展WPF都控制固有的UserControl,而不是作为常规WPF应用程序从Window控制。

Here is some of the code examples: 这是一些代码示例:

Drag Operation: 拖动操作:

<Grid MouseLeftButtonDown="box1_MouseLeftButtonDown"/>

Drop Operation: 投下操作:

<Grid AllowDrop="True" Drop="box2_Drop"/>

Thanks! 谢谢!

我的问题的答案是在这篇文章中,非常简短且很有帮助: 不允许在VS2010扩展中的WPF ToolWindow中拖放答案此答案适用于MSVS2010,但在2015年也适用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM