```
<StackPanel>
<ToggleButton x:Name="toggleButton">
Click to open first popup
</ToggleButton>
<Popup IsOpen="{Binding IsChecked, ElementName=toggleButton}" PlacementTarget="{Binding ElementName=toggleButton}" Placement="Bottom" StaysOpen="False">
<Border Background="White" BorderBrush="Black" BorderThickness="1" Padding="3">
<StackPanel>
<TextBlock>Here is somewhere for you to click once the below ComboBox or DropDownButton is open</TextBlock>
<ComboBox>
<ComboBoxItem>First</ComboBoxItem>
<ComboBoxItem>Second</ComboBoxItem>
</ComboBox>
<xctk:DropDownButton>
Here is the drop-down button
<xctk:DropDownButton.DropDownContent>
<Label>Here is the content</Label>
</xctk:DropDownButton.DropDownContent>
</xctk:DropDownButton>
</StackPanel>
</Border>
</Popup>
</StackPanel>
```
So simply placing a `DropDownButton` within a `Popup` is problematic because the user can't click away inside the hosting `Popup` in order to dismiss the `DropDownButton`. But you'll notice that the `ComboBox` does not suffer from the same problem. That's because, internally, it uses an `IsDropDownOpen` property instead of relying on `Popup.StaysOpen`. It handles various mouse and keyboard events to ensure that `IsDropDownOpen` is set to `false` at appropriate times.
`DropDownButton` needs to exhibit this same behavior if it is to be useful within a `Popup`.
Comments: ** Comment from web user: kentcb **
I'm keen to have this solved in the next release, so I've attached a fix. Sorry I cannot submit a PR because I'm behind a strict corporate proxy that won't allow it.
A summary of the changes:
* `DropDownButton.IsOpen` is used to trigger `Popup.IsOpen`. `Popup.StaysOpen` is no longer set in the template. This applies to both `DropDownButton` and `SplitButton` templates.
* Added a couple of class event handlers to determine whether `IsOpen` should be set to `false`, such as when the user clicks away from the `DropDownButton`
* Also fixed a semi-related problem with focusing on the first element in the `Popup` when it opens
I'd appreciate you incorporating this into the code base.
NOTE: the attached files are for a .NET 4.0 implementation. I believe the only change necessary for 3.5 is to replace the `SetCurrentValue` call with a property setter (`IsOpen = false`). The former is the preferred approach for WPF 4, since it does not overwrite bindings on the property.