App.xaml.cs 911 B

123456789101112131415161718192021222324252627282930
  1. using System.Windows;
  2. namespace WpfDemo
  3. {
  4. /// <summary>
  5. /// Interaction logic for App.xaml
  6. /// </summary>
  7. public partial class App : Application
  8. {
  9. public App()
  10. {
  11. new DemoWindow().ShowDialog();
  12. // diagnostic - remove after testing
  13. if (Windows.Count > 0)
  14. {
  15. var str = "";
  16. foreach (Window win in Windows)
  17. {
  18. str += win.Title;
  19. if (win.Tag is object obj)
  20. str += $" ({obj.GetType().Name})";
  21. str += "\n";
  22. }
  23. MessageBox.Show($"The following {Windows.Count} window(s) still running:\n{str}\nPress OK to copy message to clipboard.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
  24. Clipboard.SetText(str);
  25. }
  26. }
  27. }
  28. }