WPF: OnRender and Hit Testing

Posted by stefan.at.wpf on Stack Overflow See other posts from Stack Overflow or by stefan.at.wpf
Published on 2010-05-21T14:59:25Z Indexed on 2010/05/21 15:00 UTC
Read the original article Hit count: 867

Filed under:
|

Hello,

when using OnRender to draw something on the screen, is there any way to perform Hit Testing on the drawn graphics?

Sample Code

    protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
    {
        base.OnRender(drawingContext);

        drawingContext.DrawRectangle(Brushes.Black, null, new Rect(50, 50, 100, 100));
    }

Obviously one has no reference to the drawn Rectangle which would be necessary to perform hit testing or am I wrong about this? I know I can use DrawingVisual, I'm just curious if my understanding is correct, that using OnRender to draw something you can't perform any hit testing on the drawn things?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about hittest