title: Button.MouseDown
body: <p>I'm relatively new with WPF.
  I'm trying to understand the difference between MouseDownEvent and PreviewMouseDownEvent. </p>
  
  <p>I understand the WPF event strategies and i understand that the MouseDown event is a bubbling event and the PreviewMouseDown is a tunneling event. </p>
  
  <p>I also understand the order of which these events are being fired - according to this MSDN overview <a href="http://msdn.microsoft.com/en-us/library/ms742806.aspx#routing" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms742806.aspx#routing</a> (there is a diagram with example there).</p>
  
  <p>So i tried to code some my self, check this for example:</p>
  
  <pre><code>&lt;Grid x:Name="grid" Width="250"&gt;
      &lt;StackPanel Mouse.MouseDown="StackPanel_MouseDown" PreviewMouseDown="StackPanel_PreviewMouseDown"&gt;
      &lt;WPFVisualizerExample:MyButton x:Name="B1" PreviewMouseDown="B1_PreviewMouseDown" MouseDown="B1_MouseDown" Margin="5,5,5,5"&gt;
              &lt;WPFVisualizerExample:MyButton x:Name="B2" PreviewMouseDown="B2_PreviewMouseDown" MouseDown="B2_MouseDown"  Margin="5,5,5,5"&gt;
                  &lt;WPFVisualizerExample:MyButton x:Name="B3" PreviewMouseDown="B3_PreviewMouseDown" MouseDown="B3_MouseDown"  Margin="5,5,5,5"&gt;Click Me&lt;/WPFVisualizerExample:MyButton&gt;
              &lt;/WPFVisualizerExample:MyButton&gt;
      &lt;/WPFVisualizerExample:MyButton&gt;           
      &lt;/StackPanel&gt;        
  &lt;/Grid&gt;
  </code></pre>
  
  <p>I have an event handler for each of the events (the preview and non-preview) and i wanted to see what is happening, which of the event is being thrown (<strong>i have a message box shown for each event</strong>).</p>
  
  <p>The 'MyButton' user control simply extends the base Button and override the OnMouseDown and OnPreviewMouseDown to set the e.Handled false:</p>
  
  <pre><code>    protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
      {            
          base.OnMouseDown(e);
          e.Handled = false;
      }
  
      protected override void OnPreviewMouseDown(System.Windows.Input.MouseButtonEventArgs e)
      {            
          base.OnPreviewMouseDown(e);
          e.Handled = false;
      }
  </code></pre>
  
  <p>(tried with this and without this).</p>
  
  <p>According to the MSDN overview (in the link above), if i have 3 elements then the events route should be as follows:</p>
  
  <p>PreviewMouseDown (tunnel) on root element.</p>
  
  <p>PreviewMouseDown (tunnel) on intermediate element #1.</p>
  
  <p>PreviewMouseDown (tunnel) on source element #2.</p>
  
  <p>MouseDown (bubble) on source element #2.</p>
  
  <p>MouseDown (bubble) on intermediate element #1.</p>
  
  <p>MouseDown (bubble) on root element.</p>
  
  <p>So I expected the the <strong>message boxes</strong> to be shown according to the above.
  From some reason - which I don't understand only the preview events are being thrown (according to what the MSDN says Preview_B1=>Preview_B2=>Preview_B3).
  My expectations were:
  Preview_B1=>Preview_B2=>Preview_B3=>NonPreview_B3=>NonPreview_B2=>NonPreview_B1.</p>
  
  <p>But the non-preview events are not being thrown at all.</p>
  
  <p>So basically I don't understand the route of the events, from MSDN overview I understood that the route starts from the root element, goes down (tunnel) to the source element and then back up (bubble) to the root element, but this is not what happening in practice.</p>
  
  <p>It is really important for me to understand how this events are working, i probably miss-understand something basic here, your help will be appreciated. </p>
  
  <p>THANX!!
  -Gili</p>