How to display Suggestions in ‘on screen keyboard’ for a textbox in Windows Phone app?

In the standard Windows Phone functions like messaging or Email App, when you enter a text, you will see the list of suggestions for the text you are typing in the top of on screen keyboard.

How to display Suggestions in ‘on screen keyboard’ for a textbox in Windows Phone app? - 1
How to display Suggestions in ‘on screen keyboard’ for a textbox in Windows Phone app? – 1

Similarly, we can display the suggestions for a textbox in the on screen keyboard in our Windows Phone App too with the help of Input Scope(Chat or Text InputScopeName).

How to display Suggestions in ‘on screen keyboard’ for a textbox in Windows Phone app?

Just set the InputScope of the textbox to “Text” like the sample sourecode given below

<TextBox Name="textBox1" Text="">

<TextBox.InputScope>

<InputScope >

<InputScopeName NameValue="Text"/> </InputScope>

</TextBox.InputScope>

</TextBox>

If you want to try this in codebehind , you can use the below C# code instead

InputScope inputScope = new InputScope();
InputScopeName inputName = new InputScopeName();
inputName.NameValue = InputScopeNameValue.Text;
inputScope.Names.Add(inputName);
textBox1.InputScope = inputScope;

Run the WP7 Application and start enter few characters in the textbox , you should see the suggestions now 🙂

How to display Suggestions in ‘on screen keyboard’ for a textbox in Windows Phone app? - 2
How to display Suggestions in ‘on screen keyboard’ for a textbox in Windows Phone app? – 2

    2 Comments

  1. Talv
    April 7, 2012
    Reply

    why dont you just add the inputscope attribute to do this :S

    does exactly the same thing in a single line of code instead of 6

  2. April 21, 2012
    Reply

    Thanks Talv . Works too 🙂

Leave A Reply

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

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...