7

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 !

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72

2 Answers2

8

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.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • The link to 4.5 does not show(?)...but 4.0 works. [Hit Testing in the Visual Layer](https://msdn.microsoft.com/en-us/library/vstudio/ms752097%28v=vs.100%29.aspx) – ΩmegaMan Jun 29 '15 at 21:52
0

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

Magnus Ahlin
  • 655
  • 1
  • 6
  • 18
  • 1
    This will not prevent the lower ellipse from getting hit, IsHitTestVisible=false makes that element invisible to hit testing, but it does not affect elements below the affected element. – John Melville Dec 27 '14 at 18:40