在 WPF 中创建拖动完成时的上下文菜单
我正在开发类似于 Maya 的 HyperGraph 的节点图视图,在其中我可以通过拖放连接节点。因为目标节点可以有多个输入,所以我想创建一个临时上下文菜单来选择以下模型中建议的输入:
http://www.pixtur.org/images/uploaded/0000/0696/large.jpg
我尝试了很长一段时间来触发创建或打开上下文菜单的。看起来 Win32 TrackPopupMenu 大致可以实现我正在寻找的功能。是否有 WPF/C# 等效项?
谢谢 像素图
I am working on a node-graph-view similar to Maya's HyperGraph in which I can connect Nodes with drag and drop. Because the target-node can have several Inputs, I want to create a temporary ContextMenu to select the input as suggesting in the following mock-up:
http://www.pixtur.org/images/uploaded/0000/0696/large.jpg
I tried for quite a time to trigger the creation or opening of a context-menu. It looks like the Win32 TrackPopupMenu does roughly, what I'm looking for. Is there an WPF / C# equivalent?
Thanks
pixtur
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议另一种解决方案:
在此示例中,右键单击按钮将弹出一个上下文菜单,其中包含一个条目(“复制”)。如果单击“复制”上下文菜单项,则会生成控制台输出。
I would suggest another solution:
In this example a button will raise a context menu with one entry ("Copy") on right click. If the "Copy" context menu item is clicked, a console output is generated.
我使用以下代码将上下文菜单附加到列表视图 gricolumn 标题:
在代码隐藏中,我在鼠标向上事件上设置列表的 ContextMenu 属性,以便显示上下文菜单:
变量 ContextMenu指的是我之前创建的上下文菜单实例,您也可以在鼠标事件处理程序中创建上下文菜单。
我不确定这是否有帮助,因为我不知道你如何进行拖放,但值得一试
I use the following code to attach a contextmenu to a listview gricolumn header:
In the codebehind i set the
ContextMenu
property of the list on the mouse up event, in order to show the context menu:The variable ContextMenu refers to a contextmenu instance that i created bfeorehand, you could also create the ContextMenu in the Mouse event handler.
I'm not sure if this helps as I dont know how you do the drag/drop, but it is worth a try