如何在WPF中进行模态对话? [英] How do make modal dialog in WPF?

查看:148
本文介绍了如何在WPF中进行模态对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WPF中编写我的第一个应用程序,并希望让用户在模态对话窗口中输入一些数据。显然,这在WPF中并不简单,因为父窗口保持完全启用,创建新子窗口的方法不会停止,并且等待子窗口调用Close()。相反,它只是继续前进。这不是我想要的。



如何让子窗口打开,让父窗口等待孩子关闭,然后父窗口继续执行?

解决方案

您是否尝试使用 ShowDialog 方法?



不要忘记设置所有者对话窗口上的属性。当Alt + Tabbing等等


时,这将避免奇怪的行为

I am writing my first application in WPF and want to have the user input some data on a modal dialog window. Apparently, this is not simple to do in WPF, because the parent window stays fully enabled, and the method that created the new child window doesn't stop and wait for the child window to call Close(). Instead it just keeps going forward. This is not what I want.

How can I get the child window to open, and have the parent window wait for the child to close before the parent window continues executing?

解决方案

Did you try showing your window using the ShowDialog method?

Don't forget to set the Owner property on the dialog window. This will avoid weird behavior when Alt+Tabbing, etc.

这篇关于如何在WPF中进行模态对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆