using System.Windows; namespace WpfDemo { /// /// Interaction logic for App.xaml /// public partial class App : Application { public App() { new DemoWindow().ShowDialog(); // diagnostic - remove after testing if (Windows.Count > 0) { var str = ""; foreach (Window win in Windows) { str += win.Title; if (win.Tag is object obj) str += $" ({obj.GetType().Name})"; str += "\n"; } MessageBox.Show($"The following {Windows.Count} window(s) still running:\n{str}\nPress OK to copy message to clipboard.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Clipboard.SetText(str); } } } }