Indish
Indish

Reputation: 749

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?

Upvotes: 0

Views: 758

Answers (1)

Vloxxity
Vloxxity

Reputation: 980

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

Upvotes: 1

Related Questions