Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF combobox like popup

Tags:

c#

wpf

I am trying to make a custom popup that will be similar to the combobox one.

I used a Toggle button as the header and a Popup for the content.

<ToggleButton IsChecked="{Binding ElementName=Popup, Path=IsOpen, Mode=TwoWay}">
    ...
</ToggleButton>
    
<Popup x:Name="Popup" StaysOpen="False">
    ...
</Popup>

This works great except one case. When the popup is opened and I click on the ToggleButton again, the popup disappears but then reopens right after.

Looks like when I clicked on the toggle button, Popup detected that the mouse click is outside of the popup so it closes itself and sets ToggleButton.IsChecked = false. Then the click sets IsChecked = true so the popup opens again.

Edit: In such case I would like the popup to close just like the behavior of a Combobox.

Is there a way to solve this problem?

like image 350
Steve Avatar asked Oct 14 '25 08:10

Steve


1 Answers

Locate the popup on top of the button so the user can't click on the button. You can do it easily with Placement and so on.

like image 50
15ee8f99-57ff-4f92-890c-b56153 Avatar answered Oct 16 '25 21:10

15ee8f99-57ff-4f92-890c-b56153



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!