Determining the Enter key is pressed in a TextBox

前端 未结 5 1326
无人共我
无人共我 2021-02-02 07:08

Consider a XAML TextBox in Win Phone 7.

  

The goal here is that when the user presses the Enter

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 07:34

    Disabling the keyboard

    Was faced with the same problem; the examples above only gives details about how to trap the keyboard press event (which answers the question), but to disable the keyboard, onclick or enter, I just have the focus set to another control altogether.

    Which will result in disabling the keyboard.

    private void txtCodeText_KeyDown(object sender, KeyEventArgs e)
    {
        if(e.Key.Equals(Key.Enter))
        {
            //setting the focus to different control
            btnTransmit.Focus();
        }
    }
    

提交回复
热议问题