如何按ESC關閉窗口?
在InitializeComponent();下面增加KeyDown事件,如:
public ModifyPrice() { InitializeComponent(); this.KeyDown += ModifyPrice_KeyDown; } private void ModifyPrice_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape)//Esc鍵 { this.Close(); } }