简体   繁体   English

Windows和事件订阅(WPF)

[英]Windows and event subscription (WPF)

Is there a way to suscribe one window event for look when another window close itself? 有没有一种方法可以在另一个窗口关闭时为一个窗口事件提供外观? I need to ask some details in the other window, once I get the details, then I close that window, the main window needs to know that. 我需要在另一个窗口中询问一些细节,一旦获得细节,然后关闭该窗口,主窗口就需要知道这一点。

Thanks. 谢谢。

Whichever class constructs the window should be able to subscribe an eventhandler from the handler window to the .Closing event of the window you want it to respond to. 无论哪个构造窗口的类都应该能够将事件处理程序从处理程序窗口预订到您希望其响应的窗口的.Closing事件。

SomeWindow window = new SomeWindow();
window.Closing += otherWindow.ClosingEventhandler;
window.Show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM