title: WPF popup wont close even with StaysOpen="false"
body: <p>I am trying to achieve the following:</p>
  
  <ol>
  <li>User brings up a context menu in a datagrid. </li>
  <li>User selects a context menu item which then opens a popup and displays some information. </li>
  <li>when the user clicks anywhere else in the application, not in the popup, the popup closes. </li>
  </ol>
  
  <p>Everything works fine until I come to closing the popup. </p>
  
  <p>From searching elsewhere I am aware that I need Staysopen to be set to false ( which it is)
  I also read the best way is to bind the IsOpen value to a property in the view model and set its binding to 2 way ( also done )</p>
  
  <p>As a side note I have found that if I add a textbox and click inside the box, when I then click outside the popup it closes as desired. </p>
  
  <p>Another thing I unsuccessfully tried as a workaround was to programmatically set the keyboard focus on the text box to get the "autoclose" functionality I desired.  </p>
  
  <p>Here is code:</p>
  
  <p>xaml - </p>
  
  <pre><code>&lt;Popup Name="PredictionsPopup" Height="200" Width="200" AllowsTransparency="false" StaysOpen="False" IsOpen="{Binding DisplaySummaryPopup, Mode=TwoWay}"&gt;
              &lt;StackPanel Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"&gt;
                  &lt;TextBlock Text="here is some stuff" /&gt;
                  &lt;TextBox Name="hiddenBox" Text="moo"/&gt;
              &lt;/StackPanel&gt;         
          &lt;/Popup&gt;
  </code></pre>
  
  <p>Codebehind that sets the property on the viewmodel when the menu item is selected.</p>
  
  <pre><code> private void CurrentPredicitions_OnClick(object sender, RadRoutedEventArgs e)
          {
  
              PredictionsPopup.Placement = PlacementMode.MousePoint;
              ViewModel.DisplaySummaryPopup = true;
  
          }
  </code></pre>
  
  <p>Viewmodel property</p>
  
  <pre><code>public bool? DisplaySummaryPopup
          {
              get
              {
                  return this.displaySummaryPopup;
              }
  
              set
              {
                  this.displaySummaryPopup = value;
                  RaisePropertyChanged(() =&gt; this.DisplaySummaryPopup);
              }
          }
  </code></pre>
  
  <p>Please let me know if you need anymore details.</p>