title: C# canvas going overpainted
body: <p>I have a <code>Canvas</code> in my <code>MainWindow</code> and I draw a line there. When it draws over the width/height of my <code>Canvas</code>, the drawing continues in my <code>MainWindow</code>. Is there a mistake in my code or is that normal?</p>
  
  <pre><code>&lt;Canvas x:Name="coordinateSystem" HorizontalAlignment="Right" Height="580" Margin="0,10,283,0" VerticalAlignment="Top" Width="1024" Cursor="Cross" UseLayoutRounding="False"/&gt;
  </code></pre>
  
  <p>Here is my function I call everytime when I get a new coordinate for my line:</p>
  
  <pre><code>// xOld, yOld and t are static
  // t represents the time
  private void drawPoly(double value) 
  {    
      t++;
      Point pOne = new Point(xOld, yOld);
      Point pTwo = new Point(t, value);
  
      GeometryGroup lineGroup = new GeometryGroup();
      LineGeometry connectorGeometry = new LineGeometry();
      connectorGeometry.StartPoint = pOne;
      connectorGeometry.EndPoint = pTwo;
      lineGroup.Children.Add(connectorGeometry);
      System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
      path.Data = lineGroup;
      path.StrokeThickness = 1;
      path.Stroke = path.Fill = Brushes.Red;
  
      coordinateSystem.Children.Add(path);    
  
      xOld = t;
      yOld = value;
  }
  </code></pre>
  
  <p>thx</p>
  
  <p><code>PS:</code> Is there a way to save all drawn points? I want later resize my canvas (zoom out/zoom in) or if the time going to big move my painted line in my canvas and then I need to draw all points again.</p>