Displaying a Software Input Panel (Windows Phone, Xbox 360)
The Complete Sample
The code in this topic shows you the technique. You can download a complete code sample for this topic, including full source code and any additional supporting files required by the sample.
On systems and devices that lack a hardware keyboard, you can use Guide.BeginShowKeyboardInput to display a software input panel (SIP). This is an asynchronous process for which you can use both polling and callback-style techniques to retrieve user input.
|For more information about programming asynchronous methods, see Working with Asynchronous Methods in XNA Game Studio.|
To show a software keyboard
Call Guide.BeginShowKeyboardInput to begin display of the keyboard.
On Windows Phone and Windows, the player index must always be PlayerIndex.One.
kbResult = Guide.BeginShowKeyboardInput(PlayerIndex.One, "Here's your Keyboard", "Type something...", ((typedText == null) ? "" : typedText), GetTypedChars, null);
Note If you require a secure input panel that does not display typed characters, use the Guide.BeginShowKeyboardInput (PlayerIndex, String, String, String, AsyncCallback, Object, Boolean) overload that takes a Boolean parameter specifying whether to hide user input.
When IASyncResult.IsCompleted is true, call Guide.EndShowKeyboardInput to retrieve the characters typed in the input panel.
|Because this process displays a Windows Phone-generated input panel that resizes the display, you should not do any lengthy processing within a few frames of calling BeginShowKeyboardInput or Guide.EndShowKeyboardInput. If you do so, your game may experience odd graphical artifacts as the phone returns the screen back to the resolution and orientation used by your game.|