Bug in geometry Hit-Testing Bug in geometry Hit-Testing wpf wpf

Bug in geometry Hit-Testing


It seems like hit-testing considers the position of the shapes to which was applied a reverse order of transformations. This would explain why my path is intersected only and not fully inside the RectangleGeometry argument of MyCanvas.GetVisuals method.

Waiting for a better response, i implemented the hit-test with a not hit-testing method, now part of MyCanvas class:

public List<DrawingVisual> GetVisuals(Rect Area){   this.Hits.Clear();   foreach (DrawingVisual DVisual in this.Visuals) {       if (Area.Contains(DVisual.DescendantBounds))           this.Hits.Add(DVisual);   }   return this.Hits;}

EDIT:

As Mike Danes (moderator on MSDN forum) explains in this thread:

"Is it really possible that this is a bug in geometry hit-testing?"

I'm 99% sure this is a bug. Drawing and hit testing should use the same transform order. The reason it works correctly with TransformGroup is because this way you only push only one transform in the drawing context and this avoids the wrong multiplication order in the hit test drawing context.Note that this has nothing to do with the fact that the order used in TranformGroup is different from the push order.