Search code examples
c#wpfcoordinatespolylinecoordinate-transformation

How can I get real point position of WPF Polyline points?


I am trying to draw some marks (red circles) over my WPF PolyLine points.

So I can get position of each PolyLine.Point and draw my mark.

enter image description here

And this is ok, but problem appears when Polyline Stretch is applied!

So when Stretch is applied point coordinates not equals to real position of point on screen.

enter image description here

Any ideas how to get real point position on screen when Stretch is applied?


Solution

  • You may use the Transform from the Polyline's RenderedGeometry:

    var transform = polyline.RenderedGeometry.Transform;
    
    foreach (var point in polyline.Points)
    {
        var transformedPoint = transform.Transform(point);
    }