StayOpen=“False” with inherited popups

微笑、不失礼 提交于 2019-12-11 14:38:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!