tags:

views:

190

answers:

1

Hello, I have a Path in WPF and I'd like to get the single points of this path. Is this somehow possible? (I used a WPF built-in PathSegment and I'd like to get the points that WPF calculated)

Thanks for any hint!

+1  A: 

Geometry.GetFlattenedPathGeometry returns "a polygonal approximation of the Geometry object." You can then iterate over the figures and segments of the flattened Geometry: each figure should consist of a single PolyLineSegment, from which you can iterate over the Points property to get the points along the path. Thus:

  PathGeometry g = Path.Data.GetFlattenedPathGeometry();

  foreach (var f in g.Figures)
    foreach (var s in f.Segments)
      if (s is PolyLineSegment)
        foreach (var pt in ((PolyLineSegment)s).Points)
          Debug.WriteLine(pt);
itowlson
thanks for your reply and sorry for my late reply. i just checked this and unfortunately it doesn't work that fine. in my case I have a quadratic bezier segment and i get points with a x dfference of each about 30, while the difference shouldn't be more than 1 ):
stefan.at.wpf