title: WPF TextBox with popup
body: <p>I'm working with WPF Popup. A popup contains some keyboard. 
  I want to open a popup when a user clicks on a text box and do not hide a popup while textbox has the focus.
  Also I need to hide a popup when a user clicks somewhere away from a popup.
  Here's the xaml code:</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;StackPanel&gt;
          &lt;TextBox  x:Name="textBox" GotKeyboardFocus="textBox_GotFocus" MouseDown="textBox_MouseDown" /&gt;
  
          &lt;Popup x:Name="popup" Width="100" Height="100" PlacementTarget="{Binding ElementName=textBox}" Placement="Bottom"
          StaysOpen="{Binding ElementName=text,Path=IsKeyboardFocused}"&gt;
              &lt;Grid Background="Blue"&gt;
  
              &lt;/Grid&gt;
          &lt;/Popup&gt;
  
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Here's the c# code:</p>
  
  <pre><code> private void textBox_GotFocus(object sender, KeyboardFocusChangedEventArgs e)
          {
              popup.IsOpen = true;
          }
  
  private void textBox_MouseDown(object sender, MouseButtonEventArgs e)
          {
              popup.IsOpen = true;
          }
  </code></pre>
  
  <p>I found that the binding can help:</p>
  
  <pre><code>StaysOpen="{Binding ElementName=,Path=IsKeyboardFocused}" 
  </code></pre>
  
  <p>But the TextBox never hides. Also if I set StaysOpen="False" the TextBox never shows</p>