How to programmatically make the Windows Phone 7 Keyboard open
Posted by robkraft on May 15, 2011
I wrote a Windows Phone 7 application with a search page. When a user clicks on the search icon I wanted to take them to the search page, set focus on the text box, and have the on phone keyboard pop open for the TextBox. Since the TextBox was the only control on the page I figured it would get focus and the keyboard would open up; but it didn’t work that way. To make it work, I used the Focus event on the TextBox. The only trick to this is that you can’t call the .Focus on the TextBox in page constructor because the XAML has not all rendered and events are not yet tied to all the page elements. So, you need to create a load event in the constructor, and have the load event call Focus on your textbox. This will cause the keyboard to open as soon as someone navigates to the page.
this.Loaded += new RoutedEventHandler(SearchPage_Loaded);
void SearchPage_Loaded(object sender, RoutedEventArgs e)