Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

Input Scope of a TextBox defines the information related to the scope of the data provided by the input method and use to define the layout of the onscreen keyboard of the device. It is present in the "System.Windows.Input" namespace and exposed in TextBox as a property called "InputScope".

 

You might be wondering what is this property and why should one use it. Ok, let us discuss this in depth with a small sample. After reading this chapter, you will be able to understand it more and use it on your business requirement. Don't forget to share this tutorial links to others as this will help them to learn more.

 

 

Index - Windows Phone 7 (Mango) Tutorial

 

What is Input Scope?

InputScope is a property exposed by TextBox control of Windows Phone 7. It's a property of type InputScope and present in the namespace "System.Windows.Input" and inherits DependencyObject. InputScope takes parameter InputScopeName which is of type InputScopeNameValue.

 

Generally, this can be declared for TextBox similar way as shown in the below code snippet:

 

WP7.1 Demo - InputScope (Full)

 

You can also reduce the no. of lines by specifying the value in this format:

WP7.1 Demo - InputScope (Single Line)

 

This property represents the information related to the scope of the data provided by the input method. We will learn more about it in the next point with some sample code.

 

What is Input Scope name Value?

InputScopeNameValue is an enum type which represents the different way of text input pattern. It has a no. of enum values. Let's see the meta data of the enum here. Just read the comments in each line to know more about the enum values.

public enum InputScopeNameValue
{
    EnumString = -5, // The text input pattern for enum string
    Xml = -4, // The text input pattern for xml
    Srgs = -3, // The text input pattern for srgs
    RegularExpression = -2, // Gets or sets a regular expression to be used as a input pattern
    PhraseList = -1, // Gets a collection of phrases to be used as input patterns
    Default = 0, // The default handling of input commands
    Url = 1, // The text input pattern for an URL
    FullFilePath = 2, // The text input pattern for full file path
    FileName = 3, // The text input pattern for a file name
    EmailUserName = 4, // The text input pattern for email username
    EmailSmtpAddress = 5, // The text input pattern for SMTP email address
    LogOnName = 6, // The text input pattern for logon name
    PersonalFullName = 7, // The text input pattern for Personal full name
    PersonalNamePrefix = 8, // The text input pattern for prefix of personal name
    PersonalGivenName = 9, // The text input pattern for person's given name
    PersonalMiddleName = 10, // The text input pattern for middle name of a Person
    PersonalSurname = 11, // The text input pattern for surname of a person
    PersonalNameSuffix = 12, // The text input pattern for suffix of a person name
    PostalAddress = 13, // The text input pattern for complete postal address
    PostalCode = 14, // The text input pattern for postal code/zip code
    AddressStreet = 15, // The text input pattern for Street address
    AddressStateOrProvince = 16, // The text input pattern for state or provience
    AddressCity = 17, // The text input pattern for city name
    AddressCountryName = 18, // The text input pattern for Country name
    AddressCountryShortName = 19, // The text input pattern for short country name
    CurrencyAmountAndSymbol = 20, // The text input pattern for amount and symbol of currency
    CurrencyAmount = 21, // The text input pattern for currency amount
    Date = 22, // The text input pattern for a calendar date
    DateMonth = 23, // The text input pattern for numeric month in a calendar date
    DateDay = 24, // The text input pattern for numeric day in a calendar date
    DateYear = 25, // The text input pattern for numeric year in a calendar date
    DateMonthName = 26, // The text input pattern for name of the month
    DateDayName = 27, // The text input pattern for name of the day
    Digits = 28, // The text input pattern for digits
    Number = 29, // The text input pattern for number
    OneChar = 30, // The text input pattern for a single character
    Password = 31, // The text input pattern for a password
    TelephoneNumber = 32, // The text input pattern for telephone number
    TelephoneCountryCode = 33, // The text input pattern for telephone with country code
    TelephoneAreaCode = 34, // The text input pattern for telephone with area code
    TelephoneLocalNumber = 35, // The text input pattern for local telephone number
    Time = 36, // The text input pattern for time
    TimeHour = 37, // The text input pattern for hour of time
    TimeMinorSec = 38, // The text input pattern for minutes or seconds of time
    NumberFullWidth = 39, // The text input pattern for full width number
    AlphanumericHalfWidth = 40, // The text input pattern for alpha-numeric half-width chars
    AlphanumericFullWidth = 41, // The text input pattern for alpha-numeric full-width chars
    CurrencyChinese = 42, // The text input pattern for Chineese currency
    Bopomofo = 43, // The text input pattern for Chineese phonetic scripts "Bopomofo"
    Hiragana = 44, // The text input pattern for Hiragana script
    KatakanaHalfWidth = 45, // The text input pattern for Katakana half-width chars
    KatakanaFullWidth = 46, // The text input pattern for Katakana full-width chars
    Hanja = 47, // The text input pattern for Hanja chars
    Yomi = 48, // The text input pattern for Yomi chars
    Text = 49, // The text input pattern for text string
    Chat = 50, // The text input pattern for chat string
    Search = 51, // The text input pattern for search string
    NameOrPhoneNumber = 52, // The text input pattern for Name or Phone number
    EmailNameOrAddress = 53, // The text input pattern for Email address
    Private = 54, // The text input pattern for private value
    Maps = 55, // The text input pattern for map input string
    NumericPassword = 56, // The text input pattern for numeric password
    ApplicationEnd = 57, // The text input pattern for application end
    Formula = 57, // The text input pattern for formula
}

 

Demonstration

In this section, we will demonstrate some of the enum values of InputScope and check how it changes the onscreen keyboard of the device. Here we will discuss the following 6 input scope values:

 

 

WP7.1 Demo - InputScope (Default)

Default Inputscope:

 
<TextBlock Text="Default: " FontSize="30"/>
<TextBox Width="450" Height="75" InputScope="Default"/>


This is the default input scope of a TextBox in Windows Phone 7. If you don't specify, it takes the same input and shows the default keyboard on screen.
WP7.1 Demo - InputScope (EmailSmtpAddress)
Email SMTP Adress Inputscope:
 
<TextBlock Text="EmailSmtpAddress: " FontSize="30"/>
<TextBox Width="450" Height="75" InputScope="EmailSmtpAddress"/>


The above code will show a different onscreen keyboard with the special keys like '@', '.com' etc. which are specific to email address.
WP7.1 Demo - InputScope (Number)
Number Inputscope:
 
<TextBlock Text="Number: " FontSize="30"/>
<TextBox Width="450" Height="75" InputScope="Number"/>


If you specify number input scope to your TextBox control, it will only show the numeric keypad in the screen. Other keys will not be visible in the screen. For details, see the screenshot.
WP7.1 Demo - InputScope (PostalCode)
Postal Code Inputscope:
 
<TextBlock Text="PostalCode: " FontSize="30"/>
<TextBox Width="450" Height="75" InputScope="PostalCode"/>


Postal Input scope will add some additional keys in the default view of onscreen keyboard. It has numeric keys along with special keys.
WP7.1 Demo - InputScope (TelephoneCountryCode)
Telephone Country Code Inputscope:
 
<TextBlock Text="TelephoneCountryCode: " FontSize="30"/>
<TextBox Width="450" Height="75" InputScope="TelephoneCountryCode"/>


In this input scope type, you will have a numeric keypad in the onscreen keyboard that looks as a telephone keypad.
WP7.1 Demo - InputScope (Time)
Time Inputscope:
 
<TextBlock Text="Time: " FontSize="30"/>
<TextBox Width="450" Height="75" InputScope="Time"/>


In this input scope, you will have basic keys to enter the characters require to specify time value. This includes numbers, special characters.

 

 

Here I demonstrated 6 different input scope examples. Change the input scope name value for the other types and see how your onscreen keyboard looks like inside the device. Hope this chapter was helpful for you to understand this property attribute. Use it properly in various cases while developing your application.

 

Reference: MSDN Documentation

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.