如何保持上下文菜单在模式对话框后面可见

发布于 2024-09-25 17:31:49 字数 249 浏览 0 评论 0原文

我正在开发一个带有下拉按钮的 WPF 应用程序。当“展开”时,它会在上下文菜单中显示自定义用户控件。该控件包括两个按钮,一个用于“打开”,一个用于“保存”。这个想法是让每个按钮显示适当的文件对话框。

我的问题是,当显示对话框时,ContextMenu(以及控件)关闭。我想在对话框打开时保持它可见。同时,我希望对话框保留在其前面/上方。

所以我的问题是,这可以在 WPF 中完成吗?我怀疑这与父窗口处理 LostFocus 事件的方式有关,但我不确定。

I'm working on a WPF application which has a dropdown button. When "expanded", it displays a custom UserControl inside a ContextMenu. This control includes two buttons, one for Open and one for Save. The idea is for each of these buttons to display the appropriate file dialog.

My problem is that, when the dialog is displayed, the ContextMenu (and thus the control) closes. I'd like to keep it visible while the dialog is open. At the same time, I'd like the dialog to remain in front of/over it.

So my question is, can this be done at all in WPF? I suspect it has to do with how the parent Window handles the LostFocus event, but I'm not sure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放手` 2024-10-02 17:31:49

好吧,在快速原型应用程序中直接使用 Popup 类后,我找不到任何方法来获得我想要的行为。当模式对话框显示时,弹出窗口会消失 (StaysOpen == false),或者它在对话框顶部保持可见 (StaysOpen == true)。

但是,我确实找到了一种近似于我想要的行为的解决方法:只需在对话框关闭后重新打开 Popup (IsOpen = true) 即可。

Well, after working directly with the Popup class in a quick prototype app, I couldn't find any way to get the behavior I wanted. Either the Popup disappears when the modal dialog is displayed (StaysOpen == false), or it stays visible on top of the dialog (StaysOpen == true).

However, I did find a work-around that approximates the behavior I wanted: simply re-open the Popup (IsOpen = true) after the dialog is closed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文