wpf怎么在textbox上设置输入法
- 原创
- |
- 浏览: 1387
- |
- 更新:
方法/步骤
-
方法如下,此方法不会限制只能输入英文,只是设定初次获得控制项焦点的输入法。
-
Style的写法:
<Setter Property="InputMethod.InputScope">
<Setter.Value>
<InputScope>
<InputScope.Names>
<InputScopeName NameValue="AlphanumericHalfWidth"></InputScopeName>
</InputScope.Names>
</InputScope>
</Setter.Value>
</Setter>
-
<TextBox.InputScope>
<InputScope>
<InputScope.Names>
<InputScopeName NameValue="AlphanumericHalfWidth"/>
</InputScope.Names>
</InputScope>
</TextBox.InputScope>
-
如果是DataGrid要放在Datagrid.Cellstyle
Code的写法:
InputScope scope = new InputScope();
InputScopeName name = new InputScopeName();
name.NameValue = InputScopeNameValue.AlphanumericHalfWidth;
scope.Names.Add(name);
TextBox txt = d as TextBox;
txt.InputScope = scope;
END