user242408
user242408

Reputation:

Hit Testing in 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!

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 !

Upvotes: 7

Views: 9750

Answers (2)

Magnus Ahlin
Magnus Ahlin

Reputation: 655

Cant you put a smaller ellipse in the middle of it and set IsHitTestVisible="false" ?

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564323

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.

Upvotes: 8

Related Questions