Home > DeveloperSection > Forums > How main WPF window knows when secondary WPF window is closed
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    December-09-2013 11:47 PM

 WPF WPF 
Ratings:


 1 Reply(s)
 1126  View(s)
Rate this:

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.



ezra heywood
ezra heywood

Total Post:145

Points:1019
Posted on    December-09-2013 11:59 PM

Hi Manoj,

You can use like this.

   public void CreateNewWindow()

   {

       Window wind=new Window();

       wind.Closing+=yourClosingHandler;

   }

   void yourClosingHandler(object sender, CancelEventArgs e)

   {

     //do some staff

   }


Don't want to miss updates? Please click the below button!

Follow MindStick