title: Drawing Line to next point in realtime
body: <p>My current program allows the user to click a point, then click another point (at least 20 pixels away) and draws a line between the 2 points.  I've used a Polyline so that this can be done multiple times.  Though the set of all the lines only appear after all the click are done.</p>
  
  <pre><code>void DrawingCanvas_MouseUp(object sender, MouseButtonEventArgs e) {
          Point position = e.GetPosition(this);
  
          if (leftList == null) {
              //starting a new set
              leftList.Add(position);
              lastPoint = position;
              return;
          }
          //calculate distance, i.e. end click
          double a = lastPoint.X - position.X;
          double b = lastPoint.Y - position.Y;
          double distance = Math.Sqrt(a * a + b * b);
          if (distance &gt; 20) {
              //continue to add to list
              leftList.Add(position);
              lastPoint = position;
          } else {
              //end of the line
              paint();
              leftList = new PointCollection(); 
          }
  
      }
  
      private void paint() {
          Polyline line = new Polyline();
          line.Visibility = System.Windows.Visibility.Visible;
          line.StrokeThickness = 2;
          line.Stroke = System.Windows.Media.Brushes.Black;
          line.Points = leftList;
          myCanvas.Children.Add(line);
      }
  </code></pre>
  
  <p>So my question is two-fold:</p>
  
  <p>A) How do I make it so that after each click the new line is immediately added.</p>
  
  <p>B) How do I render a line between the last point and where the mouse cursor is currently at (i.e. just before you choose your next point)</p>