title: How to get Line-s from Canvas Children in WPF
body: <p>I'm trying to delete some lines I have drawn on my canvas, and my idea was to use the coordinates of the Line controls from <code>Canvas.Children</code>.</p>
  
  <p>My initial code looked like this:</p>
  
  <pre><code>    var ax = Mouse.GetPosition(Canvas).X;
      int mx1 = (int)ax - (eraserSize / 2);
      int mx2 = (int)ax + (eraserSize / 2);
      var ay = Mouse.GetPosition(Canvas).Y;
      int my1 = (int)ay - (eraserSize / 2);
      int my2 = (int)ay + (eraserSize / 2);
  
  foreach(Line l in Canvas.Children)
  {
      if((l.X1 &lt; mx1 &amp;&amp; lX2 &gt; mx2) &amp;&amp; (l.Y1 &lt; my1 &amp;&amp; lY2 &gt; my2))
      {
          Canvas.Children.Remove(l);
      }
  }
  </code></pre>
  
  <p>But of course it doesn't work since there are other controls that it cannot cast to Line.</p>
  
  <p>I tried using <code>if(l.Name == "LineName")</code> to put these in a <code>Line[]</code> or <code>Control[]</code> but nothing works, and I'm not sure what else to try, other then just painting over it...</p>