在WPF命中测试测试、WPF

2023-09-04 10:34:48 作者:雾里窥知心意

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

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层有关如何做到这一点的详细信息),你应该能够检查IntersectionDetail的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.