控制Windows Phone 7键盘 [英] Controlling the Windows Phone 7 Keyboard

查看:69
本文介绍了控制Windows Phone 7键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始学习如何使用XAML和SilverLight为Windows Phone 7编写应用程序。关于如何用键盘做几件事,我有几个问题。这是一个清单:

I recently started learning how to write Apps for the Windows Phone 7 using XAML and SilverLight. I have several questions on how to do several things with the keyboard. Here is a list:

1。有没有可用于显示/隐藏键盘的方法?

1. Are there any methods that can be used to show/hide the keyboard?

2。我的应用程序中有几个TextBox,我只想接受数字。但是,当TextBox接收焦点时键盘自动出现,键盘以字母模式显示键盘,迫使用户每次手动将键盘
切换为数字模式,我相信这是不可取的。有没有办法指定键盘最初出现的模式?

2. I have several TextBoxes in my App that I only want to accept digits. However, when the keyboard automatically comes up when the TextBox receives focus, the keyboard displays the keyboard in letter mode, forcing the user to manually switch the keyboard to numeric mode every time, which I'm sure is not desirable. Is there a way to specify which mode the keyboard initially comes up in?

3。因为在我的任何TextBox中只使用了数字1-9,有没有办法只显示这些数字(或者它是否需要我,0),当然还有退格键和删除键?我显然可以设计我自己的几个按钮的键盘,
但是因为我已经在使用TextBoxes,所以我希望有一个更简单的方法。有吗?

3. Because it is only the digits 1-9 that are used in any of my TextBoxes, is there a way to show only these digits (or if it requires me to, 0 as well) and, of course, the backspace and delete keys? I could obviously design my own keyboard of several buttons, but since I am already using TextBoxes, I was hoping there would be an easier way. Is there?

我认为大部分功能都可用,因为我猜他们中的很多都会用在大多数计算器或财务应用程序中,这些并不是一个不常见的类别。有人可以帮我吗?谢谢。

I would think that most of these capabilities would be available, since I would guess that many of them would be used in most calculator or financial Apps, which are not an uncommon category. Can someone help me here? Thanks.

Nathan Sokalski

njsokalski@hotmail.com

http://www.nathansokalski.com/

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

推荐答案

1。我不认为任何方法可以在Windows手机中手动显示/隐藏屏幕键盘。

1. I dont think any method available to manually show/hide the onscreen keyboard in windows phone.

2。要显示文本框获得焦点时的数字,只需将该TextBox的"InputScope"属性指定为"Number"。

2. And to show the digits when a textbox receives focus, simply specify the 'InputScope' property of that TextBox to 'Number'.

<TextBox Name="phoneNumberBox" InputScope="Number">

这就是全部。

或者您也可以使用以下方法

or else you can use the following approach as well

<TextBox Name="txtPhoneNumber" >
    <TextBox.InputScope>
        <InputScope>
            <InputScopeName NameValue="Number" />
        </InputScope>
    </TextBox.InputScope>
</TextBox>

从C#也可以这样做,

InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();

name.NameValue = InputScopeNameValue.Number;
scope.Names.Add(name);

txtPhoneNumber.InputScope = scope;

对于所有可用的格式,
检查这个

For all the available Formats, Check this

希望这有帮助!!


这篇关于控制Windows Phone 7键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆