I have a custom Canvas control (inherited from Canvas) overlaid over a large area of User Controls. The idea is to draw paths between user controls (i.e. connector lines).
我有一个自定义画布控件(继承自Canvas),覆盖在用户控件的大部分区域上。其思想是在用户控件(即连接线)之间绘制路径。
To capture mouse movement, I call Mouse.Capture(theCanvas)
on MouseDown. This works beautifully, but the user controls under the canvas obviously no longer receive mouse events. Mouse.DirectlyOver
always shows the canvas, so I can't really fake it by peeking at the current position and seeing which user control it's over.
为了捕获鼠标移动,我调用Mouse.Capture(theCanvas),在MouseDown上。这工作得很好,但是用户在画布下面的控件显然不再接收鼠标事件。鼠标。DirectlyOver总是显示画布,所以我不能通过偷看当前位置来伪装它,看看哪个用户控件已经结束。
So, I still need the Canvas for drawing paths, but how can I solve this one of the following ways:
所以,我仍然需要画布来绘制路径,但是我如何解决以下问题:
- Peek under the Canvas and see what the topmost control is right under it?
- 在画布下面偷窥,看看最上面的控件在画布下面是什么?
- Get this MouseDown -> Track MouseMoves -> MouseUp workflow to work on the canvas without mouse captures?
- 让这个MouseDown ->跟踪MouseMoves -> MouseUp工作流在画布上工作而没有鼠标捕获?
Any other ideas welcome...
任何其他想法欢迎……
1 个解决方案
#1
0
I'd agree that those are your two options. If you want to only forward some clicks to your usercontrols, then go with option 1, and hit test the controls under the canvas.
我同意你的两个选择。如果您只想将一些单击转发给您的usercontrols,那么使用选项1,并点击画布下的test控件。
If you need your usercontrols to behave as though there is nothing covering them (textboxes, buttons etc), then i'd recommend using the PreviewMouseMove event on the user control's parent, as this can pick up and optionally "handle" events before the controls get at the event, but it won't block the event if you don't set handled to true
如果你需要你的用户控件的行为好像没有覆盖(文本框、按钮等),那么我建议使用PreviewMouseMove事件在用户控制的母公司,这可以挑选和选择“处理”事件控制在事件之前,但这不会阻止事件如果你不设置为true来处理
#1
0
I'd agree that those are your two options. If you want to only forward some clicks to your usercontrols, then go with option 1, and hit test the controls under the canvas.
我同意你的两个选择。如果您只想将一些单击转发给您的usercontrols,那么使用选项1,并点击画布下的test控件。
If you need your usercontrols to behave as though there is nothing covering them (textboxes, buttons etc), then i'd recommend using the PreviewMouseMove event on the user control's parent, as this can pick up and optionally "handle" events before the controls get at the event, but it won't block the event if you don't set handled to true
如果你需要你的用户控件的行为好像没有覆盖(文本框、按钮等),那么我建议使用PreviewMouseMove事件在用户控制的母公司,这可以挑选和选择“处理”事件控制在事件之前,但这不会阻止事件如果你不设置为true来处理