Sergey
Sergey

Reputation: 11908

WPF closing all windows when user closes one of them

There's a WPF application with multiple windows. Initially there's only one window. User may go to next windows while previous are hidden. When they return back, hidden windows appear again. The problem is that when user closes some window, the hidden ones continue to run as processes. Is it possible to close all of them when user closes any.

Upvotes: 8

Views: 10706

Answers (1)

HCL
HCL

Reputation: 36765

If you want to terminate an application with all windows, you can call App.Current.Shutdown();. If you want call this on closing of any window, register to the Window.Closed event and call App.Current.Shutdown(); there in.

Through App.Current.Windows you have access to all Window-instances. You also can close them manually.

Upvotes: 23

Related Questions