WPF检测键序列 [英] WPF detect key sequence
本文介绍了WPF检测键序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的 WPF 应用程序中隐藏 groupox,并在应用程序处于活动状态(未最小化)时通过按键代码在需要时手动启用它
I would like to hide a groupox from my WPF app and to manually enable it when I need it via a keypress code when app is active(not minimized)
这个例子有时只需要一个按键就可以工作,但我需要一个序列
this example works sometimes with just one keypress, but I need a sequence
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
if (e.Key == Key.B)
{
bdgb.Visibility = Visibility.Visible;
}
}
推荐答案
例如,您可以覆盖窗口的 OnPreviewKeyDown
方法,例如:
You could for example override the OnPreviewKeyDown
method of your window, e.g.:
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
if (e.Key == Key.B)
{
//...
}
}
这篇关于WPF检测键序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文