问题描述
我有一个弹出模式,它使用 StaysOpen="False" 在你点击弹出窗口外部时自动关闭.但是,弹出窗口包含打开新弹出窗口的按钮,我想保持父弹出窗口(使用 StaysOpen 属性的那个)打开.
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.
这甚至可能吗?
推荐答案
您只需要一个 bool
属性即可将数据绑定到 Popup.IsOpen
属性然后你可以随时打开和关闭它:
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;
这篇关于StayOpen=“假"带有继承的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!