Rob Kraft's Software Development Blog

Software Development Insights

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.

public SearchPage
this.Loaded += new RoutedEventHandler(SearchPage_Loaded);

void SearchPage_Loaded(object sender, RoutedEventArgs e)

One Response to “How to programmatically make the Windows Phone 7 Keyboard open”

  1. alfahish said


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: