对于 Windows应用商店应用,是否等同于PreviewKeyDown
?它不可用。
我遇到与described here:
完全相同的问题我有一个ListBox,上面有一个TextBox。我想使用箭头键从ListBox导航到TextBox。目的是如果选择ListBox中的第一个项目,并且用户键入,则TextBox将获得焦点。
答案 0 :(得分:8)
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();
}
祝你好运!