如何按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();
}
}