title: Seemingly strange WPF behaviour: textbox lostfocus event and button click event
body: <p>The following behaviour is occurring with the .net 4.0 code set out further below:</p>
  
  <p>Click on textbox so it gains focus, and then click button:</p>
  
  <ol>
  <li>As code stands, lostfocus handler is called, but not buttonclick handler  </li>
  <li>Comment out MessageBox.Show("handlelostfocus") and then click handler is called </li>
  <li>Set breakpoint in handlelostfocus and breakpoint is hit, but click handler is not called</li>
  </ol>
  
  <p>Are these bugs or behaviour by design - if later, is there any further explanation?</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication4.MainWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Title="MainWindow" Height="350" Width="525"&gt;
          &lt;Grid&gt;
              &lt;Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="216,194,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /&gt;
              &lt;TextBox Height="23" HorizontalAlignment="Left" Margin="197,108,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /&gt;
          &lt;/Grid&gt;
      &lt;/Window&gt;
  
  public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
              textBox1.LostFocus += new RoutedEventHandler(handlelostfocus);
          }
  
          private void handlelostfocus(object sender, RoutedEventArgs e)
          {
              MessageBox.Show("handlelostfocus");
          }
  
          private void button1_Click(object sender, RoutedEventArgs e)
          {
              MessageBox.Show("click");
          }
      }
  </code></pre>