Is there an equivalent to the PreviewKeyDown
for a Windows Store App? It isn\'t available.
I have exactly the same problem as described her
Ah, tricky. Handling key events isn't super-obvious. Here's what you want:
public MainPage()
{
this.InitializeComponent();
Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += (s, args) =>
{
if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown
|| args.EventType == CoreAcceleratorKeyEventType.KeyDown)
&& (args.VirtualKey == VirtualKey.Up))
{
MoveUp();
}
else if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown
|| args.EventType == CoreAcceleratorKeyEventType.KeyDown)
&& (args.VirtualKey == VirtualKey.Down))
{
MoveDown();
}
};
}
private void MoveUp()
{
// this part is up to you
throw new NotImplementedException();
}
private void MoveDown()
{
// this part is up to you
throw new NotImplementedException();
}
Best of luck!