开发者

Problem HitTesting a geometry in WPF

开发者 https://www.devze.com 2023-02-25 19:06 出处:网络
My WPF application has a canvas on which I draw tables and lines that connect them. When a user clicks on a table or line, I capture the MouseDown event of that control and do开发者_开发知识库 various

My WPF application has a canvas on which I draw tables and lines that connect them. When a user clicks on a table or line, I capture the MouseDown event of that control and do开发者_开发知识库 various stuff in the background. The problem is that while the tables are big, and so present no problems, the lines are only a couple of pixels thick, so clicking it's difficult and annoying because you need pinpoint precision.

My question is: is there a way to give a Geometry a bit of "margin" that is invisible but still captures clicks? (or any other solution that would work for what I'm trying to achieve, maybe there's a better approach, like hit-testing on the canvas maybe??).

Thanks in advance!!


In WPF, you can draw with transparent colors (with 0 for alpha channel). If you draw an extra wide line like this below the normal one, that will respond to hittests, even though it's invisible.

0

精彩评论

暂无评论...
验证码 换一张
取 消