【问题标题】:How to intercept Enter key in AutoSuggestBox?如何拦截 AutoSuggestBox 中的 Enter 键?
【发布时间】:2015-11-12 09:01:43
【问题描述】:

AutoSuggestBox 中的“Enter”键调用 QuerySubmitted 事件,例如单击图标。这是一个 Windows 10 项目。

我需要区分 Enter 键,因为我使用它转到下一个字段。我尝试了 KeyDown 事件,但它没有被调用。

我该怎么做?

【问题讨论】:

    标签: c# xaml win-universal-app


    【解决方案1】:

    不要问我为什么,但你需要使用KeyUp 事件,一切正常。 例如:

    private void ContactsBox_KeyUp(object sender, KeyRoutedEventArgs e)
    {
        if (e.Key == Windows.System.VirtualKey.Enter)
        {
            //some stuff here
        }
    }
    

    【讨论】:

    • 谢谢... 很奇怪为什么 KeyDown 不起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-13
    • 1970-01-01
    相关资源
    最近更新 更多