有时输入只能让用户输入英文,那么如何设置输入只能英文? ide
首先在xaml 写一个 TextBox ,给他一个名字。code
<TextBox x:Name="txt"></TextBox>
而后在构造使用 System.Windows.Input.InputMethod 能够设置 IME 和输入是否能够是中文。blog
System.Windows.Input.InputMethod.SetIsInputMethodEnabled(txt, false);
设置IME关掉get
InputMethod.SetPreferredImeState(txt,InputMethodState.Off);
固然也能够在页面写it
<TextBox InputMethod.IsInputMethodEnabled="False"></TextBox>
注意用户能够粘贴中文,能够检测用户是否输入有中文。class