windows phone 键盘开发
键盘操作
键盘操作很简单,直接代码
使用默认键盘
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.Default; //<--Here
scope.Names.Add(name);
txtK1.InputScope = scope;
进入一个页面,自动弹出键盘
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
//This code opens up the keyboard when you navigate to the page.
txtK1.UpdateLayout();
txtK1.Focus();
}
聊天用键盘
含有一个smiley = smily 微笑表情
//You can set the Keyboard Input Scope by using either XAML or code.
//See the XAML file for the XAML version.
//The code version is below.
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.Chat; //<--Here
scope.Names.Add(name);
txtK2.InputScope = scope;
//To create keyboard 2, you can use any of the following Input Scopes.
//--------------------------------------------------------------------
// Chat
// Text
Url
含有。Com
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.Url; //<--Here
scope.Names.Add(name);
txtK3.InputScope = scope;
含有。com和@图标
//You can set the Keyboard Input Scope by using either XAML or code.
//See the XAML file for the XAML version.
//The code version is below.
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.EmailNameOrAddress; //<--Here
scope.Names.Add(name);
txtK4.InputScope = scope;
//To create keyboard 4, you can use any of the following Input Scopes.
//--------------------------------------------------------------------
// EmailNameOrAddress
// EmailSmtpAddress
// EmailUserName
Name or Phone Number
就是直接显示数字键盘(含有 123 图标 点击 会打开数字键盘)
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.NameOrPhoneNumber; //<--Here
scope.Names.Add(name);
txtK5.InputScope = scope;
//To create keyboard 5, you can use any of the following Input Scopes.
//--------------------------------------------------------------------
// NameOrPhoneNumber
PostalAddress
和上面的区别是 (显示&123图标,点击后不光显示数字还有一些常用标点符号)
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.PostalAddress; //<--Here
scope.Names.Add(name);
txtK6.InputScope = scope;
//To create keyboard 6, you can use any of the following Input Scopes.
//--------------------------------------------------------------------
// AddressStreet
// CurrencyAmountAndSymbol
// CurrencyChinese
// PostalAddress
// PostalCode
// Time
PhoneNumber
显示数字键盘
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.TelephoneNumber; //<--Here
scope.Names.Add(name);
txtK7.InputScope = scope;
//To create keyboard 7, you can use any of the following Input Scopes.
//--------------------------------------------------------------------
// TelephoneAreaCode
// TelephoneCountryCode
// TelephoneLocalNumber
// TelephoneNumber