5

How can I programmatically display the soft input panel (SIP)/keypad, via code. (I dont have a text-box on which I can specify the InputScope).

Bob
  • 22,810
  • 38
  • 143
  • 225
Raj Rao
  • 8,872
  • 12
  • 69
  • 83
  • 2
    Why do you want to? Users will expect that the SIP is for entering text in to a textbox (or similar). – Matt Lacey Oct 15 '10 at 08:07
  • I want to display the text in textblock. In addition, the problem with relying on the textbox is that the SIP is displayed only when the textbox has focus. I have only one UI that updates based on what the user is typing, other elements update based on this main input. What I am trying to work around is the fact that if the user clicks elsewhere on my screen, the SIP disappears and the user has to click inside the textbox again to display it – Raj Rao Oct 15 '10 at 21:38

2 Answers2

11

From Jeff Blankenburgs 31 Days of Windows Phone 7:

Sometimes, you want to get keyboard input from your user, even when you don’t want to present them with an actual TextBox. There’s probably plenty of ways around this, but I’ve been using a handy one that is simple to accomplish. (If you’re searching for a reason to do this, think of a game of Hangman. I don’t want the keyboard visible always, but I also don’t want a TextBox on the screen.)

Put a button on your page.

Put a TextBox on your page, but make sure it’s hidden from the user’s view.

Either position it off screen, make it completely transparent (and in the absolute background), or some other method that allows it to get added to your visual tree, but doesn’t let the user see it.

Set an event handler on your button that sets Focus() to the hidden textbox when it’s clicked.

That’s it! This will allow you to show the keyboard without the user seeing a textbox.seeing a textbox.

Greg Bray
  • 14,929
  • 12
  • 80
  • 104
0

If you're using XNA, you can use Guide.BeginShowKeyboardInput but i'm not sure that that is allowed if you're doing silverlight. But i will second the comment on "why?" because if you don't have a textbox, how are you showing the user what they are typing?

John Gardner
  • 24,225
  • 5
  • 58
  • 76