title: Popup with StaysOpen = False
body: <p>I have set up a simple control with three rectangles, each of which has a popup attached to it. Initially all three popups are set to open (IsOpen=True), and all three have the StaysOpen flag set to false. The XAML for this is posted below.</p>
  
  <p>From the MSDN documentation on StaysOpen, I gather that when it is false, clicking the mouse outside of the popup should close the popup. What I am finding is that if I click the mouse completely outside the application, then all three popups close correctly. However, if I click within the WPF window itself then only the top popup closes. The other two remain visible.</p>
  
  <p>Does anybody know what is happening here, and what I can do to ensure that all three popups close as expected?</p>
  
  <pre><code>&lt;Window x:Class="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;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*"/&gt;
              &lt;RowDefinition Height="30"/&gt;
              &lt;RowDefinition Height="*"/&gt;
              &lt;RowDefinition Height="30"/&gt;
              &lt;RowDefinition Height="*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Rectangle x:Name="Rect1" Fill="DarkBlue"/&gt;
          &lt;Rectangle x:Name="Rect2" Fill="Orange" Grid.Row="2"/&gt;
          &lt;Rectangle x:Name="Rect3" Fill="DarkRed" Grid.Row="4"/&gt;
          &lt;Popup PlacementTarget="{Binding ElementName=Rect1}" Placement="Right" IsOpen="True" StaysOpen="False"&gt;
              &lt;Border BorderBrush="Black" BorderThickness="2" Background="Wheat" Width="200" Height="100"&gt;
                  &lt;TextBlock&gt;Popup 1&lt;/TextBlock&gt;
              &lt;/Border&gt;
          &lt;/Popup&gt;
          &lt;Popup PlacementTarget="{Binding ElementName=Rect2}" Placement="Right" IsOpen="True" StaysOpen="False"&gt;
              &lt;Border BorderBrush="Black" BorderThickness="2" Background="Wheat" Width="200" Height="100"&gt;
                  &lt;TextBlock&gt;Popup 2&lt;/TextBlock&gt;
              &lt;/Border&gt;
          &lt;/Popup&gt;
          &lt;Popup PlacementTarget="{Binding ElementName=Rect3}" Placement="Right" IsOpen="True" StaysOpen="False"&gt;
              &lt;Border BorderBrush="Black" BorderThickness="2" Background="Wheat" Width="200" Height="100"&gt;
                  &lt;TextBlock&gt;Popup 3&lt;/TextBlock&gt;
              &lt;/Border&gt;
          &lt;/Popup&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>