private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.KeyStates==Keyboard.GetKeyStates(Key.Escape)) { this.Close(); } }