Sheldon
Sheldon

Reputation: 2628

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.

Upvotes: 2

Views: 1472

Answers (1)

Jimmy Hoffa
Jimmy Hoffa

Reputation: 5967

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.

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

Upvotes: 5

Related Questions