Search code examples
c#.netwpfsystem.drawing

How to do hit testing inside a closed shape composed only of lines (no fill)


How to do it? The figure is an instance of DrawingVisual and DrawingContext.DrawLine is used to draw closed shapes.

As a makeshift solution, i draw a semi transparent line, almost invisible, of the thickness equal to that of the entire shape. This way it responds to hit testing. Is there a better way to do it?


Solution

  • This comment is the right answer:

    I was going to recommend using an enclosing border and use hit testing over that. But you have kind of implemented the same thing. (AngelWPF)