I faced a similar problem, and could never retrieve the PathFiguers defined in the Data attribute. I could manipulate it only if I defined the PathGeomtry in my code, here is an example
Path p = new Path();
p.SetValue(Path.NameProperty, "myPath");
PathGeometry g = new PathGeometry();
PathFigure f = new PathFigure();
f.StartPoint = new Point(10, 10);
LineSegment seg = new LineSegment();
seg.Point = new Point(10, 100);
LineSegment seg2 = new LineSegment();
seg2.Point = new Point(100, 100);
LineSegment seg3 = new LineSegment();
seg3.Point = new Point(100, 10);
f.Segments = new PathSegmentCollection();
f.Segments.Add(seg);
f.Segments.Add(seg2);
f.Segments.Add(seg3);
g.Figures = new PathFigureCollection();
g.Figures.Add(f);
p.Data = g;
p.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
p.SetValue(Canvas.TopProperty, 10);
p.SetValue(Canvas.LeftProperty, 10);
this.Children.Add(p);
Then later based on a click event I retrieved the Path data
public void onCLick(object sender, EventArgs e)
{
Path p = (Path)this.FindName("myPath");
PathGeometry g = (PathGeometry)p.Data;
foreach (PathFigure f in g.Figures)
{
foreach (PathSegment seg in f.Segments)
{
seg.ToString();
}
}
}
Hopefully this issue is fixed in the next release, because it is really painful to define path data in code.
Thanks
Yasser Makram
My Blog: http://www.silverlightrecipes.com
Sr. Architect
Santeon Inc. Microsoft Silverlight Partner, Solution Provider