I faced a problem. I have two WPF windows in my project and I open the second WPF window by pressing the button on the main WPF window. But when I close the second window I need the first window to know that this happened and to do some action. How do I make this? I tried isLoaded and Application.Current.Windows, but both of them didn't work as I needed. Any ideas? Thank you in advance.
Asked
Active
Viewed 253 times
0
-
possible duplicate of [Run code on WPF form close](http://stackoverflow.com/questions/1374528/run-code-on-wpf-form-close) – WiredPrairie Apr 21 '13 at 15:49
-
No, the event handler will work in the same event tree, but I need to cross the two windows, two event trees. – user2151660 Apr 21 '13 at 15:57
-
What is an "event tree"? FYI: The answer you accepted is no different than the suggestion I linked to (other than it has code). – WiredPrairie Apr 21 '13 at 18:04
1 Answers
1
You can use like this.
public void CreateNewWindow()
{
Window wind=new Window();
wind.Closing+=yourClosingHandler;
}
void yourClosingHandler(object sender, CancelEventArgs e)
{
//do some staff
}

Javidan
- 566
- 1
- 9
- 25