如何在WPF中进行模式对话框? [英] How to make modal dialog in WPF?

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

问题描述

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

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?

推荐答案

您是否尝试使用不要忘记设置所有者属性到主窗口.这样可以避免Alt + Tabbing等奇怪的行为.

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

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

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