title: How to display only 2 lines when a mousemove event occurs on a canvas
body: <p>I'm trying to make two lines that follows the mouse every time the MouseMove event occurs. I can create the two lines for the event, but the problem is that they will create two lines for every MouseMove. Here's my code. I'm using WPF and C#.</p>
  
  <pre><code>    private void CanvasMouseMove(object sender, MouseEventArgs e)
      {
          double xPos = e.GetPosition(m_Grid).X;
          double yPos = e.GetPosition(m_Grid).Y;
  
          Line vertLine = new Line();
          Line horzLine = new Line();
  
          vertLine.X1 = xPos;
          vertLine.Y1 = 0;
          vertLine.X2 = xPos;
          vertLine.Y2 = m_Grid.Height;
  
          horzLine.X1 = 0;
          horzLine.Y1 = yPos;
          horzLine.X2 = m_Grid.Width;
          horzLine.Y2 = yPos;
  
          vertLine.StrokeThickness = 1;
          horzLine.StrokeThickness = 1;
  
          vertLine.Stroke = Brushes.Black;
          horzLine.Stroke = Brushes.Black;
  
          m_Grid.Children.Add(vertLine); //m_Grid is my Canvas
          m_Grid.Children.Add(horzLine);
  
          m_Grid.UpdateLayout();
      }
  </code></pre>