We have an application developed in WPF. i wanted to implement one functionality here.
my main window, lets call it as MainWindow. And the windows that can be opened from the MainWindow are independent. they are not child windows. They have links from main window.

MainWindow - Window1 - Window11 - Window111

MainWindow - Window2 - Window22- Window222

MainWindow - Window3 - Window33 - Window333

MainWindow - Window4 - Window44- Window444

MainWindow - Window5 - Window55 - Window555

MainWindow - Window6 - Window66- Window666

So here it goes. The first level of windows like Window1,Window2, Window3... can be directly opened from Main window. Second level opens based on selection from first level windows. Third level opens from Second level...

Now i wanted to capture all the opened windows (can be first level,second level or third level) and place them as a list in main window, in anyway possible.

6 Years
Discussion Span
Last Post by Geekitygeek

Create two events in your main window, something like WindowOpened and WindowClosed. When you open another window, it calls the WindowOpened routine, and when it closes, it calls WindowClosed.

You will have to pass a reference to your main form to each form you create.


You could take a look at the Application.OpenForms collection:

string OpenForms = "";
    foreach (Form f in Application.OpenForms)
        OpenForms += f.Name + ", ";
    if (OpenForms.Length > 2)
        OpenForms = OpenForms.Substring(0, OpenForms.Length - 2);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.