According to the above, set a delegate in the child window. Then in the child window closes the event, executes the delegate instance, and then increases the listener delegate's method in the main window ....
Consider that the ability to close the event is a special delegate. So why do you have to declare a new one? Superfluous.
So there are the following implementations:
Public Partial classMainwindow:window { PublicMainWindow () {InitializeComponent (); } Private voidButton_Click (Objectsender, RoutedEventArgs e) {Subwindow s=NewSubwindow (); S.closed+=s_closed; S.show (); } Private voidS_closed (Objectsender, EventArgs e) {MessageBox.Show ("The sub-window is going to be closed. We're going to shut it down too. "); This. Close (); } }
Description
1, here because of the special, the main window and child windows are directly called code, so you can do so. So if they are not called directly between them, then we still have to use the delegate processing.
2, the class, itself may have encapsulated a variety of delegates, we might as well look at the class definition.
"2016-11-6" "persist in Learning" "Day21" when the child window closes, synchronize close its main window (method two) "