Adding Different Inputscopes: Windows Phone Apps Development Tutorial – Part 24

Welcome back to the Windows Phone 7.5 Mango App development series. We saw how to use Canvas as a Dialog, now in this lesson we shall have a look at the different types of inputscopes available under the Windows Phone 7 and how to change the inputscope type depending upon the needs of the application.

Whenever the user has to enter data into the textboxes, he/she does so with the help of an on-screen keyboard. This on-screen keyboard is referred to as the InputScope. The Windows Phone 7 has a number of different types of inputscopes that you as a developer can choose from depending upon the type of information that you wish to collect. Providing the user with an appropriate type of inputscope for entering data makes the data entry task faster and easier for the user.


So let’s get started!

Create a new project with a unique name something like ‘InputScopeDemo’. Copy and paste the following XAML code in the Content panel grid xaml code.

<TextBox Height="72"
                    <InputScopeName NameValue="EmailNameOrAddress" />

The following line of code tells the Windows Phone 7 operating system to pop open the Email name and address type of Inputscope. You will notice that this type of Inputscope is customized to make typing the email address easy especially with the ‘.com’ key and all small alphabets.

<InputScopeName NameValue="EmailNameOrAddress" />

If you wanted a numeric inputscope to collect the telephone number all you have to do is change the NameValue attribute to TelephoneNumber

<InputScopeName NameValue="TelephoneNumber" />

You can also set the type of inputscope in C# code by entering the following code in the Textbox’s Focus event.

InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.Number;
textbox1.InputScope = scope;

In this code all you do is create an object for the InputScope class and an object for InputScopeName class.

InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();

We then set the Namevalue attribute of the object for InputScopename class to the type of input scope we need.

name.NameValue = InputScopeNameValue.Number;

All we then have to do is add the object of the InputScopeName to the object of the InputScope.


The final line of code simply sets the inputscope to the textbox.

textbox1.InputScope = scope;

For a complete list along with their individual explanation you can visit and search for InputScopeNameValue Enumeration.

In the next post, we will learn about GPS, Location API and Calling Web Services.

Posted by on , in Category Phone with Tags
Gadget freak, Apple lover, Windows Phone lover; well that’s me! I have been in this wonderful field of freelance writing for quite some time and looking forward to developing more illuminating content related to gadgets and technology, as I go along.

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + 9 =