Windows Phone Virtual Keyboards

Windows Phone 7 comes with about 57 different input scopes you can use (there’s actually 62 or so, but 5 of them give an exception when loaded).  The two most important scopes are Text and TelephoneNumber.

  • TelephoneNumber gives you the numeric keypad when the user goes to enter text.
  • Text gives you word suggestions and smiley faces like in messaging.

     image     image


Setting these in code is a little convoluted. It’s a lot easier to simply set it in the XAML, eg:
<TextBox … .. InputScope="Text" ></TextBox>

If you want to set the input scope in code, you need to construct an InputScope class instance, and add to it a InputScopeName class with the InputScopeName’s Value set to the InputScopeNameValue enum value.  It’s easiest to wrap this in an extension method:

Sub SetInputScope(ByVal textbox As TextBox, ByVal value As InputScopeNameValue
Dim scope As New InputScope
      scope.Names.Add(New InputScopeName With
{.NameValue = value})
      textbox.InputScope = scope
End Sub

Then setting the input scope in code simply becomes:



Some things to note about input scopes:

  • although you can cache an input scope, and assign it to a different textbox on an as needed basis, you have to be careful to ensure it is only assigned to one textbox at any given time. I doubt the memory minimization would be worth the effort.
  • an InputScope can have multiple InputScopeName values, but it seems like only the first one in the list is used.
  • the following InputScopeNameValue’s give a runtime error when run from the debugger:  PhraseList, RegularExpression , Srgs , Xml , EnumString


The main values you’ll want to use are:




Standard QWERTY layout


Standard layout with features such as autocorrect and text suggestion


Standard layout with .com and customized Enter key for typing URLs.


Standard layout with .com and @ key.


Standard layout with .com and @ key, and easy access to phone number layout.


Standard layout with a customized Enter key. Used to type a location to search for on a map


12-key layout


Semi-transparent layout with a Search and .com key.


Standard layout with access to phone number layout. Used to type in the SMS To field


Text input that uses intelligent features such as abbreviations

abbreviated from,d=lightweight).aspx