简体   繁体   中英

How to drop the virtual keyboard after keydown event on pressing enter in textbox

private void tbox_KeyDown_1(object sender, System.Windows.Input.KeyEventArgs e)
{
    if (e.Key == Key.Enter)
        //do something

}

What I want is that after the above keydownevent in textbox named tbox. I want the virtual keyboard visible on the phone screen to drop off, when I click Enter button. How could this be achieved?

you just need to set the focus to the page not the textbox.

private void tbox_KeyDown_1(object sender, System.Windows.Input.KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        this.Focus();
    }
}

Source: http://www.jstawski.com/archive/2011/02/16/programmatically-hiding-the-keyboard-in-windows-phone-7-wp7.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM