title: WPF MouseDown event not firing everywhere in a control
body: <p>I am currently fighting against another WPF struggle, namely mouse events.</p>
  
  <p>I basically have a very simple control (a <code>Border</code> containing a <code>Grid</code> which itself has a few <code>TextBlocks</code>). I am trying to achieve a simple behavior: Double click should turn the control into edit mode (which in fact hides the <code>TextBlocks</code> with <code>TextBoxes</code> bound to the same data.</p>
  
  <p>Nothing fancy, right? Well still, I'm struggling. The <code>MouseDoubleClick</code> linked to my <code>UserControl</code> just fires when I click in a control (like, clicking ON a <code>TextBlock</code>). If I click on an empty space between <code>TextBlocks</code>, nothing is fired. Not even <code>MouseDown</code>.</p>
  
  <p>How could I make it work so as to catch every mouse click? I assumed that linking a <code>MouseDown</code> event to a <code>Border</code> should catch every click on the border but... it ended up not catching clicks on empty parts of the border.</p>
  
  <p>Here is some draft code I made for you to run it:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;StackPanel Orientation="Vertical"&gt;
      &lt;Border Height="400" Width="400" HorizontalAlignment="Center" VerticalAlignment="Center" BorderBrush="Black" BorderThickness="2"
          MouseDown="Border_MouseDown" MouseUp="Border_mouseUp"&gt;
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="*" /&gt;
                  &lt;ColumnDefinition Width="*" /&gt;
                  &lt;ColumnDefinition Width="*" /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="*" /&gt;
                  &lt;RowDefinition Height="*" /&gt;
                  &lt;RowDefinition Height="*" /&gt;
              &lt;/Grid.RowDefinitions&gt;
  
              &lt;TextBlock Text="BLUFF" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;TextBlock Text="BLUFF" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
          &lt;/Grid&gt;
  
      &lt;/Border&gt;
  
      &lt;TextBlock Height="100" Width="300" HorizontalAlignment="Center" TextAlignment="Center" x:Name="thetext" Visibility="Collapsed"
                 Foreground="White" Background="Red" Text="CLICKED!" /&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>private void Border_MouseDown(object sender, MouseButtonEventArgs e)
  {
      thetext.Visibility = Visibility.Visible;
  }
  
  private void Border_mouseUp(object sender, MouseButtonEventArgs e)
  {
      thetext.Visibility = Visibility.Collapsed;
  }
  </code></pre>
  
  <p>Now try to click one of the "BLUFF" texts: A "CLICKED" Text will appear. Try clicking somewhere else, between the TextBlocks: Nothing happens.</p>
  
  <p>Thank you!</p>