How to make main window wait until a newly opened window closes in C# WPF?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 04:45:56

Use ShowDialog instead of Show -

Win.ShowDialog();

From MSDN -

Opens a window and returns only when the newly opened window is closed.

Use ShowDialog() method as it Opens a window and returns only when the newly opened window is closed.

syntax

Win.ShowDialog();

Although ShowDialog works fine, you may set MainWindow.IsEnabled = false if you don't like that modal window. Sometimes it's useful to see the main window.

Instead of using the .Show() property for openning/showing the window, use .ShowDialog() instead :)

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