title: Drawing lines in windows phone 7?
body: <p>I would like to draw some lines using Path. It always show me error when running the program. The error occurs at this sentence:"myPathSegmentCollection.Add(myLineSegment[i]);"
  The solution can be built. While debugging, it shows "Element is already the child of another element"</p>
  
  <p>the following is my function:</p>
  
  <pre><code>public void drawline(Point endP)
  {
      PathFigenter code hereure myPathFigure = new PathFigure();
      myPathFigure.StartPoint = endP;
  
      LineSegment [] myLineSegment = new LineSegment[5];
      Point myPoint = new Point();
      LineSegment line = new LineSegment();
      PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
      for (int i = 0; i &lt; 5; i++)
      {
          myPoint.X = i + 10.0;
          myPoint.Y = i+1.0;
          line.Point = myPoint;
          myLineSegment[i] = line;
          myPathSegmentCollection.Add(myLineSegment[i]);
      } 
  
      myPathFigure.Segments = myPathSegmentCollection;
  
      PathFigureCollection myPathFigureCollection = new PathFigureCollection();
      myPathFigureCollection.Add(myPathFigure);
  
      PathGeometry myPathGeometry = new PathGeometry();
      myPathGeometry.Figures = myPathFigureCollection;
  
      myPath.StrokeThickness = 1;
      myPath.Data = myPathGeometry;
  }
  </code></pre>
  
  <p>Is there anyone can help? THX!</p>