WP7 InputScope

qwerty

In Windows Phone development, InputScope is a property that can be attached to a TextBox control.  It is also one of the most convenient features of Silverlight for Windows Phone.

On a phone device, we cannot depend on having a keyboard to enter text in our applications.  The InputScope attached property provides a way to automatically associate a digital touch-aware keyboard to textboxes in our application.  The syntax, moreover, is extremely simple.  To create a keyboard like that shown above, all you have to do is set a value for the InputScope property like this:

<TextBox Name="myTextBox" InputScope="Text"/>

when the TextBox receives focus, the visual keyboard automatically pops up.  When focus leaves the TextBox, the keyboard will hide itself.  Additionally, the “Text” input scope has predictive text completion built in.  If you begin typing “R-I-G” and the InputScope is set to “Text”, the visual keyboard will make some suggestions on how to complete your word.

qwerty2

I showed the short syntax for the InputScope above.  In the Blend 4 RC, the xaml parser in design mode marks the short syntax as invalid (though it will still compile).  The longer syntax for setting the Input Scope looks like this:

<TextBox x:Name="myTextBox">
    <TextBox.InputScope>
        <InputScope>
            <InputScopeName NameValue="Text"/>
        </InputScope>
    </TextBox.InputScope>
</TextBox>

I am currently still using the Windows Phone April CTP Refresh, in which not all of the Input Scope implementations are complete.  Hopefully in the next drop I will be able to show more examples of the various Input Scope keyboard designs.

Using the long syntax above will allow intellisense support to provide a listing of all the input scope values that can be entered for the InputScopeNameValue.  You list out these values programmatically by using a little reflection (the Enum class in Windows Phone is a bit different than the regular C# enum class, so GetNames isn’t available):

var inputScopes = new List<string>();

FieldInfo[] array = typeof(InputScopeNameValue).GetFields(
        BindingFlags.Public | BindingFlags.Static);
foreach (FieldInfo fi in array)
{
    inputScopes.Add(fi.Name);
}

this.DataContext = inputScopes;

A simple app can be written to try out the different input scope keyboards as they become available.  If you use the code above to set the data context on your page, the following xaml should provide a select list for experimenting with different visual keyboards:

<StackPanel>
            <TextBox x:Name="myTextBox" 
        InputScope="{Binding ElementName=lbInputScopes
    ,Path=SelectedItem}"/>
<ListBox x:Name="lbInputScopes" 
            ItemsSource="{Binding}" 
            Height="500" />
</StackPanel>

Here is the full list of InputScopes that are expected to be supported, based on the current enum names for InputScopeNameValue:

1. AddressCity
2. AddressCountryName
3. AddressCountryShortName
4. AddressStateOrProvince
5. AddressStreet
6. AlphanumericFullWidth
7. AlphanumericHalfWidth
8. ApplicationEnd
9. Bopomofo
10. Chat
11. CurrencyAmount
12. CurrencyAmountAndSymbol
13. CurrencyChinese
14. Date
15. DateDay
16. DateDayName
17. DateMonth
18. DateMonthName
19. DateYear
20. Default
21. Digits
22. EmailNameOrAddress
23. EmailSmtpAddress
24. EmailUserName
25. EnumString
26. FileName
27. FullFilePath
28. Hanja
29. Hiragana
30. KatakanaFullWidth
31. KatakanaHalfWidth
32. LogOnName
33. Maps
34. NameOrPhoneNumber
35. Number
36. NumberFullWidth
37. OneChar
38. Password
39. PersonalFullName
40. PersonalGivenName
41. PersonalMiddleName
42. PersonalNamePrefix
43. PersonalNameSuffix
44. PersonalSurname
45. PhraseList
46. PostalAddress
47. PostalCode
48. Private
49. RegularExpression
50. Search
51. Srgs
52. TelephoneAreaCode
53. TelephoneCountryCode
54. TelephoneLocalNumber
55. TelephoneNumber
56. Text
57. Time
58. TimeHour
59. TimeMinorSec
60. Url
61. Xml
62. Yomi

16 thoughts on “WP7 InputScope

  1. The item lost me, in the 3rd comment of WP7 InputScope. I reckon I get what you are suggesting. I recognise what you are stating, but you should admit that you will find some opposite types on the globe who may perhaps not agree with you. I’m unequivocal and unpretentious, that way everybody experiences what I mean.

  2. For me, following line did not work correctly (List box was not getting bound to list)
    this.DataContext = inputScopes;

    Instead, I did following and it was fine.
    lbInputScopes.ItemsSource = inputScopes;

    Thanks.

  3. The item lost me, in the 3rd comment of WP7 InputScope. I reckon I get what you are suggesting. I recognise what you are stating, but you should admit that you will find some opposite types on the globe who may perhaps not agree with you.

  4. New Version Meizitang slimming tablets

    Meizitang Herbal Slimming Capsules

    Mechanism of Action of this New Version Meizitang slimming tablets:

    Accelerating the fat metabolism and reducing fat accumulation. Eliminating free radical in body and delaying skins turning senile by antioxidant.

    Features:
    1) Extracted from plants, thus it is without any toxicity, could be used safely
    2) It works as long as you take it and it’ s very easy to take, just 1 capsule/ time/ day
    3)Meizitang is processed by GMP producer, complying with sanitation standards, could be taken without worry
    4) We can produce it according to customers’ requests or OEM procedure
    5) No diarrhoea, no rebounding, reduces redundant fat but not water
    6) Soft capsule, fast to absorb

    New Version Meizitang slimming tablets Applicable For: people over 18 or under 60 years

    New Version Meizitang slimming tablets Specification: 650mgx36pills

    Usage & Dosage: 1time/day, 1capsule/time, with or without breakfast

    Storage: Store in airproof, cool, and dry conditions

    Standard Compliance: Q/KL2004-03

    Approval Code: YWSZZ [2007] No.530100-002310

    From best Meizitang New Version Manufacturers & Meizitang New Version Suppliers Directory
    http://yemade.com

  5. YING DA WANG REVIEW
    * One of most popular China Natural Sex PIlls for men& women in AU/USA/Middle East etc!
    * Giving you Rock Hard Erections Every Time
    * Increase your sex drive, control, stamina and sperm count!
    * Increase confidence!
    * Happy partner!
    [YING DA WANG EFFECTS]
    MEN: Frequent Erections, makes penis bigger and thicker, prolongs coition time (by up to 75 minutes), boosts sex drive.
    WOMEN: Useful to increase secretion of vagina, improve sex desire. After taking this product woman’s vagina will began to suck and shrink and women reach orgasm faster.
    [YING DA WANG INGREDIENTS]
    Chinese Herbal Aphrodisiac – 100% Natural and Safe Alternative – tablets adopt suoyang, xianmao, niugi, hyssop, angelica, medlar, tusizi, bugudzi and some other – rare herbal medicines which are used to nourish kidney, steadying germ cell, stimulating ardour.
    [YING DA WANG INDICATIONS]
    Natural Sex Pill For treatment of Erectional Dysfunction (ED), premature ejaculation, low potency, lack of sex drive or sex desire. Also useful as a recreational sex enhancement = penis enlargement or vagina tune-up pills.
    [YING DA WANG USAGE & DOSAGE]
    Take 1 tablet and swallow with a bit of warm water before sexual intercourse.
    For a better effect the tablet can be chewed on or taken on empty stomach
    [VALIDITY]: 3years
    [STORAGE]: Seal, moisture-proof, in a dry place
    [NOTE]
    1. Cant be impatient for quick result and overtake this product.
    2. Drink some cool water if you suffer from frequent erection or too long erection.
    3. Dont take more than 1 pill within 24 hours
    [WARNING]!
    Do not take erection herbal pills if you are pregnant, breast feeding, or under the age of 18.
    Please consult with a physician before taking this product.
    [YING DA WANG SIDE EFFECT]: the best result, and a little headache, take 1 pills per time is enough.
    Purchase male enhancement pills: Our website offer hundreds of herbal natural male enhancement pills.
    http://www.poerkan.com

  6. Meizitang botanical slimming soft gel for sale
    1.Meizitang zisu slimming pill meizitang for sale
    Lose 20-30 lbs per month 100% herbal and safe
    350mg x 30 capsules /box,

    2. Meizitang strong version bottle
    "MSV" on pills with laser , 650mg*36 pills

    3. Meizitang New Version Meizitang slimming tablets
    36 mzt soft gel for sale cheap meizitang

    4. Meizitang old version weight loss
    36 soft gel, meizitang slimming gel

    5. Meizitang botanical slimming (Blue Capsule)
    Weight loss 30 Ibs monthly.Meizitang OEM

  7. I am often to blogging and i really appreciate your content. The article has really peaks my interest. I am going to bookmark your site and keep checking for new information.Your place is valueble for me. Thanks!

Comments are closed.