I want to place a popup under a togglebutton when I click on it. In this popup I want to add button and other controls. But how can I make sure that the popup window always
Use Placement
and PlacementTarget
properties of the Popup
:)
<Popup Placement="Bottom" PlacementTarget="{Binding ElementName=myToggleButton}" IsOpen="{Binding IsChecked, ElementName=Userbtn}" StaysOpen="False" />
The thing to note here is that, if the window is moved when Popup
is open, it wont move along.. What you could do is Bind the IsOpen
property to ToggleButton
's IsChecked
and set StaysOpen
=False. Doing that, the Popup will close automatically, toggling the button back :) , also you wont be needing the C# code if you are to do this :)
OR here is a link to another SO post if it should stay open whatever the case be : Move a WPF Popup
Hope it helps :)