In our last post, I explained how to create a settings page for Windows Phone 7. In this blog post, I want to share a sample that will help you to create a keyboard input scope application for Windows Phone 7. This application will have the feature that allows you to change the input scope of the on-screen keyboard to one of the many built-in options. This sample contains code for three different ways of changing the on-screen keyboard.
I will now demonstrate how easy it is to create a keyboard input scope application for Windows Phone 7, using Visual Basic for Windows Phone Developer Tools. The keyboard input scope application can be created in 4 simple steps as follows:
- Create a sample application and add controls
- Add an event handler
- Build and debug the application
- Rebuild in the release mode before publishing
- Visual Studio 2010 Professional, Premium,
or Ultimate. If you do not have any of the releases, you can download any of
the following trial versions as per your preference: Professional, Premium, or Ultimate.
- Windows Phone Developer Tools
- Visual Basic
for Windows Phone Developer Tools – RTW
Note: You can install the newer version- Windows Phone Developer Tools 7.1 Beta
instead of the above mentioned two tools as it will take comparatively
less time. However, this sample was created using the previous version.
To create a keyboard input scope application for Windows Phone 7 application, let’s follow the 4 simple steps mentioned earlier:
Step 1 – Create a sample application and add controls
Create a sample application
- Create a new project and browse to the “Silverlight for Windows Phone” node.
- Select the “Windows Phone Application” template.
- Enter a name for the application.
- Click OK. The MainPage.xaml page is displayed.
- Click the MY APPLICATION text. In the Properties window, change the text property to “Keyboard Test App”.
- Click the page name text. In the Properties window, change the text property to “all about you”.
- To create the Pivot control, add the following XAML code:
Note: This method changes the keyboard input scope for each control. To change the input scope manually, you can add or change the value of the InputScope attribute for the required control.
Your application now looks like this:
Step 2 – Add an event handler
- Open the MainPage.xaml.vb page. The page is displayed with the following code:
- To set the keyboard input scope, add the following code:
- To create an event handler for the button click event, add the following code: Note: This method creates an event handler that stores all the information and navigates to a new screen and displays the content in a message box
There you are! Now your keyboard input scope application for Windows Phone 7 is ready! You just need to build and debug the application.
Step 3 – Build and debug the application
- To build the application, select Build > Build Solution. The project should build without any errors. If there are errors, check the earlier steps, correct the errors, and then build the application again.
- To debug the application, set the deployment target of the application to “Windows Phone 7 Emulator”.
- Select Debug > Start Debugging. The emulator window is displayed.
- To test the alphabet keyboard click “your name” text box. The keyboard to enter the alphabets is displayed.
- To test the number keyboard click “your number” text box. The keyboard to enter the numbers is displayed.
Note: To stop debugging the application, select Debug > Stop Debugging.
Step 4 – Rebuild in the release mode before publishing
- On the standard toolbar, change the configuration manager to Release.
- To rebuild the application, select Build > Rebuild. The XAP file of the application is generated, which is the package that you will have to submit in the marketplace to publish the application. You can also locate this XAP file in the Bin\Release folder.
Finally, to submit your application to the market place, you can refer to upload your application walkthrough.
Congrats! Buenos! You have successfully created a keyboard input scope application for Windows Phone 7, that too in just 4 simple steps! You can find the full source code for the settings page application here.