title: Why does not MouseLeftButtonUp fire in WPF?
body: <p>Why does not the MouseLeftButtonUp on my Canvas fire in my WPF app?
  Here is the XAML:</p>
  
  <pre><code>&lt;Grid Height="300" Width="400"&gt;
      &lt;Canvas Name="canvas" MouseMove="canvas_MouseMove" MouseLeftButtonUp="canvas_MouseLeftButtonUp" Background="LightGray"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>And the code:</p>
  
  <pre><code>    private bool hasClicked = false;
  
      public Window1()
      {
          InitializeComponent();
      }
  
      private void canvas_MouseMove(object sender, MouseEventArgs e)
      {
          if (!this.hasClicked)
          {
              this.Cursor = Cursors.None;
              this.canvas.Children.Clear();
              this.insertRectangle(false);
          }
      }
  
      private void insertRectangle(bool filled)
      {
          Rectangle rect = createRect(filled);
          Point pos = Mouse.GetPosition(this.canvas);
          Canvas.SetLeft(rect, pos.X);
          Canvas.SetTop(rect, pos.Y);
          this.canvas.Children.Add(rect);
      }
  
      private Rectangle createRect(bool fill)
      {
          Rectangle rect = new Rectangle();
          rect.Height = 50;
          rect.Width = 120;
          if (fill)
          {
              rect.Fill = new SolidColorBrush(Colors.Green);
          }
          else
          {
              rect.Stroke = new SolidColorBrush(Colors.Green);
          }
          return rect;
      }
  
      private void canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
      {
          this.hasClicked = true;
          this.insertRectangle(true);
          this.Cursor = Cursors.Arrow;
      }
  </code></pre>
  
  <p>Edit: I have tried adding a background colour to the canvas, but still the event is not fired. It seems like the MouseMove somehow overrides the MouseLeftButtonUp.</p>
  
  <p>Edit2: If I remove the MouseMove event, mouseLeftButtonUp will fire.</p>
  
  <p>Edit3: Bigger code example.
         In the insertRectangle method, if I use</p>
  
  <pre><code> Canvas.SetTop(rect, 50);
   instead of 
   Canvas.SetTop(rect, pos.Y);
  </code></pre>
  
  <p>the events fires just fine. </p>