gpt4 book ai didi

c# - Windows Store App ListBox 的 PreviewKeyDown

转载 作者:太空狗 更新时间:2023-10-29 22:52:06 24 4
gpt4 key购买 nike

对于 Windows 应用商店应用,是否有与 PreviewKeyDown 等效的东西?它不可用。

我遇到的问题与 described here: 完全相同

I have a ListBox with a TextBox above it. I would like to use the arrow keys to navigate from the ListBox to the TextBox. The intention is that if the first item in the ListBox is selected, and the user keys up, the TextBox will get focus.

最佳答案

啊,棘手。处理关键事件并不是显而易见的。这就是你想要的:

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

祝你好运!

关于c# - Windows Store App ListBox 的 PreviewKeyDown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16651616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com