WPF Get All Windows in an Application
By Michael Detras
There could be a scenario where we need to get all Window instances in our application. We can get them through the Application.Current.Windows property.
Here is an example where all windows except the main window are closed.
foreach (Window window in Application.Current.Windows)
if (window != Application.Current.MainWindow)
We may have a WPF application containing many Window objects. We may want to access a method of the MainWindow from another Window.
WPF Get All Windows in an Application (1193 Views)