Key char on Windows Phone

后端 未结 2 1931
名媛妹妹
名媛妹妹 2021-01-24 23:52

I want to determine the symbol that user entered by keypad. For example in Windows Forms KeyPressEventArgs has KeyChar property, but there is no this property for KeyEventArgs

相关标签:
2条回答
  • 2021-01-25 00:31

    As you have said e.Key and e.PlatformKeyCode don't grant success - e.Key = Key.Unknown.
    But I think you can try to do like this:

    private void myTextbox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
    {
       char added = myTextbox.Text.ElementAt(myTextbox.Text.Length - 1);
    }
    

    When the users enters symbol - check the last added to text, as I've checked it works with cyrillic. Then in the same event you can do what you want with this text or symbol.
    I've checked this on TextBox thought I don't know if your problem is concerned with it.

    0 讨论(0)
  • 2021-01-25 00:36

    You can use the Key property from the event args:

    if(e.Key == Key.Enter) { }
    
    0 讨论(0)
提交回复
热议问题