Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close all open modal dialog windows

I have a WPF application that has several modal window used for various purposes. This is easily accomplished by using the ShowDialog function. However, in my application I have a timer to measure idle time (i.e. no mouse moves or key strokes) that will cause the user to be logged off. Is there a way (when this timer fires) to find and close all open modal windows without tracking each explicitly?

Update I would also like to close any MessageBox.Show instances. Is this possible?

Thanks, Matt

like image 562
Matt Ruwe Avatar asked Sep 18 '25 19:09

Matt Ruwe


1 Answers

Have you tried to iterate the Application.Current.Windows collection, and close all these that are not the Application.Current.MainWindow?

Jogy

like image 140
Jogy Avatar answered Sep 23 '25 13:09

Jogy