Key char on Windows Phone

后端 未结 2 1959
名媛妹妹
名媛妹妹 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条回答
  •  梦毁少年i
    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.

提交回复
热议问题