"2016-11-6" "persist in Learning" "Day21" when the child window closes, synchronize close its main window (method two) "

Source: Internet
Author: User

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) "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.