开发者

Waiting for WPF window in non-WPF project

开发者 https://www.devze.com 2023-04-11 22:53 出处:网络
Why is it that if I call a WPF form from another project type (e.g. a console application or XNA game), the main application doesn\'t wait for the form to close before ending (and subsequently closing

Why is it that if I call a WPF form from another project type (e.g. a console application or XNA game), the main application doesn't wait for the form to close before ending (and subsequently closing the form)?

I know with a dialog box I can make the main class wait for a reponse, how can开发者_C百科 I make it do that with my form?


You can open the window in modal mode using the ShowDialog method - the ShowDialog method only returns after the window was closed. Otherwise you can either wait until the Closed event is fired or wait until Application.Windows collection is empty (meaning the application has no WPF windows left).

For more information about window closing in WPF, refer to this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号