1

Here is my code that does not work:

TheTextBox.InputScope = new InputScope();
TheTextBox.InputScope.Names.Add( 
    new InputScopeName( InputScopeNameValue.Number ) );

No special keyboard shows up when I tap on the TextBox. I just get the standard keyboard.

I would like to get this to work but Windows 8 apparently doesn't support this. I have searched for answers to this , but only found solutions that say to change the XAML. That is not a solution for me because I dislike having a bunch of UserControls just to have a variety of input scopes.

I have added this code to the Loaded event handler for the text control. It still didn't work there, as one internet answer suggested.

I tried using "Number" and "TelephoneNumber" and neither worked in code.

I am using Visual Studio 2012 and a Windows Store C# app project.

Thanks.

Dave

4

1 回答 1

3

重新排序:

var inputScope = new InputScope();
inputScope.Names.Add(new InputScopeName( InputScopeNameValue.Number ) );
TheTextBox.InputScope = inputScope;

显然,一旦您设置了InputScope属性,它就不会观察/观察发生在Names. 所以,在你的代码中,它总是空的。我已经更改了它以创建范围,Add然后在完成后设置它。

它适用于我的测试。

于 2013-10-01T17:24:36.540 回答