Detecting the user pressing F10 in WPF
In addition to Yacoder's response, use the following to check for the F10 key:
case Key.System: if (e.SystemKey == Key.F10) { // logic... }
The SystemKey property will tell you which System key was pressed.
F10 launches the window menu. It's the same in all Windows apps.
It seems that Key.System
is the expected value for the F10 key.
Answer with DataContext:
public partial class BankView : UserControl { public BankView() { InitializeComponent(); this.KeyDown += new KeyEventHandler(BankView_KeyDown); } private void BankView_KeyDown(object sender, KeyEventArgs e) { try { switch (e.Key) { case Key.F4: ((BankViewModel)DataContext).OpenAccount(); break; } } catch (Exception ex) { ... } }