【问题标题】:Is there any way to find whether "#" key is pressed in OnKeyDown event of TextBox?有没有办法在TextBox的OnKeyDown事件中找到“#”键是否被按下?
【发布时间】:2012-09-26 07:03:03
【问题描述】:

我正在 Windows Phone 中开发应用程序。我需要TextBox的KeyDown事件中的要求是,我需要知道“#”或“。”在文本框中按下键。谁能帮我解决这个问题?

【问题讨论】:

  • 我尝试了 UnKnown key 和 PlateformKey 代码...
  • 调试时按“#”或“。”并在 KeyDown 事件中检查其 KeyCode。当您知道键码时,您可以使用它们来检测它们何时被按下。

标签: c# windows-phone-7 xaml windows-phone


【解决方案1】:
    private void TextBox_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.xxxx || e.PlatformKeyCode == xxxx) //xxxx is the keycode for your desired keys
        {
           //do work here
        }
    }

我觉得应该可以

【讨论】:

  • 在 windows phone 7 上运行的任何应用程序都将在 windows phone 8 上运行
  • 但是对于 Windows Phone 8 中的所有未知键,我得到了相同的 Plateform 代码。我无法使用 PlateformkeyCode 进行区分..
  • 您是专门为 windows phone 8 制作的吗?如果是,那我就不知道了,因为我没有 SDK 来测试它。它可以在 windows phone 7 上运行,因此根据专家的说法应该可以在 windows phone 8 上运行。
  • 这部分 SDK 在 WP7 和 WP8 上是相同的。
猜你喜欢
  • 2014-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-04
  • 2020-05-08
  • 1970-01-01
  • 1970-01-01
  • 2015-12-30
相关资源
最近更新 更多