Jonas Stawski

Everything .NET and More

Programmatically hiding the keyboard in Windows Phone 7 (WP7)

I was looking for a way to programmatically hide the keyboard in WP7 and was searching for some WP7 API method, but couldn’t find one. Then it dawn on me that the keyboard automatically hides when the TextBox control looses focus. So I decided to give it a try by setting the focus on another control and it worked:

   1: //focus the current page
   2: this.Focus();
   3: //or focus another control
   4: ListBox1.Focus();

It is very easy and straight forward. This is very nice trick for when you use the enter button of the keyboard to emulate a button click, like in a search box.

Happy programming!

Comments (7) -

Hey Now Jonas,

Nice One!

Thx 4 the info,
Catto

Reply

NIce One

Reply

Thank you!

Reply

Thank you mate. Was looking for the same thing - hide the KB. Clever thing, just to loose the focus of the textbox Smile

Reply

in my case, problem with last control and I used this.focus() in my control evening,... it workign fine

thank you

Reply

Nice one....

Reply

nice one, Thanks

Reply

Add comment

biuquote
Loading