title: How to set children property in a canvas event handler?
body: <p>I've got a canvas and inside it will be a shape. That canvas has a <code>MouseLeftButtonDown</code> event handler. I then went to move the shape in the canvas to a new location however nothing happens.</p>
  
  <p>Here is how the shape is added:</p>
  
  <pre><code>public MainWindow()
      {
          InitializeComponent();
          Rectangle ShapeRect = new Rectangle() { Width=10,Height=10,Fill=Brushes.Blue};
          Canvas_1.Children.Add(ShapeRect);            
      }
  </code></pre>
  
  <p>Here is the event handler:</p>
  
  <pre><code>private void Canvas_1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
      {
          Canvas c = Canvas_1;
          var firstchild = c.Children[0];
          var RectCopy = c.Children.OfType&lt;Rectangle&gt;().FirstOrDefault();              
  
          Canvas.SetTop(RectCopy, Canvas.GetTop(RectCopy) + 500);
          Canvas.SetLeft(RectCopy, Canvas.GetLeft(RectCopy) + 500);
      }
  </code></pre>
  
  <p>I've tested the code and it has no errors and all lines run but clearly have no effect. I think it's due to the fact that <code>RectCopy</code> isn't <code>ShapeRect</code>. Any different solution or answers is welcome. Thanks.</p>