问题
I have a popup modal that is using StaysOpen="False" to automatically close when you click outside of the popup. However the popup contains buttons that open new popup windows and I want to keep the parent popup (the one using the StaysOpen attribute) open.
Currently what is happening is you click a button inside the popup and new popup appears, the parent one stays open (which is intended). But when you close one of the child popups the parent one closes.
I need the parent popup to only close when focus is lost on anything outside of itself OR the child popups.
Is this even possible?
回答1:
You just need a bool
property to data bind to the Popup.IsOpen Property and then you can open and close it whenever you like:
XAML
<Popup IsOpen="{Binding IsPopupOpen}">
<TextBlock Text="I'm a Popup" />
</Popup>
C#
// Open Popup
IsPopupOpen = true;
// Close Popup
IsPopupOpen = false;
来源:https://stackoverflow.com/questions/21464557/stayopen-false-with-inherited-popups