在WPF命中测试 [英] Hit Testing in WPF

查看:446
本文介绍了在WPF命中测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个椭圆画布和我做选中测试就可以了。 我每次点击椭圆的行程,测试通过。 如果我点击椭圆的中间,测试失败。 这是好事!

I have an Ellipse on a Canvas and I'm doing Hit Testing on it. Every time I click the stroke of the Ellipse, the test passes. If I click in the middle of the Ellipse, the test fails. This is good!

我填写之后这样的椭圆: myEllipse.Fill =新的SolidColorBrush(Colors.Blue); , 测试pasess还当我点击中间的椭圆

After I fill the ellipse like this: myEllipse.Fill = new SolidColorBrush(Colors.Blue);, the test pasess also when I click in the middle of the Ellipse.

我如何禁用此? (即使当椭圆被填满后,该测试将当我点击中间失败) 谢谢!

How can I disable this? (even when Ellipse is Filled, the test will fail when I click in the middle) Thanks !

推荐答案

如果你做你自己的命中测试(见的点击测试,在Visual层有关如何做到这一点的详细信息),你应该能够检查<一href="http://msdn.microsoft.com/en-us/library/system.windows.media.intersectiondetail.aspx">IntersectionDetail的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.media.geometryhittestresult.aspx">GeometryHitTestResult是 IntersectionDetail.Intersects ,而不是 IntersectionDetail.FullyContains

If you do your own hit testing (see Hit Testing in the Visual Layer for details on how to do this), you should be able to check the IntersectionDetail of the GeometryHitTestResult is IntersectionDetail.Intersects, and not IntersectionDetail.FullyContains.

这篇关于在WPF命中测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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