如何知道单击画布中的哪个项目 - WPF [英] how to know which item in canvas is clicked - WPF

查看:81
本文介绍了如何知道单击画布中的哪个项目 - WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个WPF应用程序来绘制图形并为dat图生成xml。

我有一个工具箱中的块列表。这些块在运行时被拖入画布。当我右键单击拖动的块时,我需要根据单击的块打开一个新窗口。 fr dat,我可以知道点击了哪个块..



提前感谢..

I''m making a WPF application for drawing graph and generating xml for dat graph.
I have a list of blocks in a toolbox. these blocks are dragged into a canvas at runtime. when I right click on a dragged block, I need to open a new window depending on the block clicked. fr dat, hw can I know whic block is clicked..

thanks in advance..

推荐答案

如果您能理解路由事件,那么将能够找出点击来自的确切控制 - 通过 [ ^ ] 。
If you can understand Routed Events, then will able to figure out the exact control the click is coming from - go through this[^].


这是一种错误的方法。相反,你应该直接处理你想要处理的元素点击并忽略其他元素。



问题只是反OOP和反事件的结果 - 定向思维,应该修复。



-SA
This is a wrong approach. Instead, you should directly handle a click on the element you want to handle and ignore others.

The question is just the result of anti-OOP and anti-event-oriented thinking, which should be fixed.

—SA


这篇关于如何知道单击画布中的哪个项目 - WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆