---
title: "How main WPF window knows when secondary WPF window is closed"  
description: "How main WPF window knows when secondary WPF window is closed"  
author: "Manoj Bhatt"  
published: 2013-12-09  
updated: 2013-12-09  
canonical: https://www.mindstick.com/forum/1760/how-main-wpf-window-knows-when-secondary-wpf-window-is-closed  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How main WPF window knows when secondary WPF window is closed

I [faced](https://www.mindstick.com/forum/23284/c-sharp-problem-faced) a problem. I have two WPF [windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) in my [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) and I open the [second](https://answers.mindstick.com/qa/41761/how-did-the-second-industrial-revolution-influence-women-s-roles-in-society) [WPF window](https://www.mindstick.com/forum/1333/wpf-window-not-closing) by pressing the [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) on the main WPF window. But when I [close](https://yourviews.mindstick.com/story/1687/rubbing-hands-close-up-benefits) 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](https://www.mindstick.com/articles/43878/making-the-best-use-of-the-options-trade-ideas)? [Thank you in advance](https://answers.mindstick.com/qa/40482/why-was-1968-a-year-of-tension-and-turmoil-list-10-events-1-being-the-best-and-10-the-worst-thank-you-in-advance).

## Replies

### Reply by Anonymous User

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   }
```


---

Original Source: https://www.mindstick.com/forum/1760/how-main-wpf-window-knows-when-secondary-wpf-window-is-closed

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
