using System.Windows; using System.Windows.Input; namespace Explorer.App; /// /// Close helpers for windows opened with . /// sets , which throws on modeless windows. /// internal static class ModelessWindowClose { public static void EnableEscape(Window window) => window.PreviewKeyDown += (_, e) => { if (e.Key != Key.Escape) { return; } window.Close(); e.Handled = true; }; }