TextBox
禁用输入法
InputMethod.IsInputMethodEnabled=”False”
<TextBox Name="TBoxIp" PreviewTextInput="TBoxIp_PreviewTextInput" InputMethod.IsInputMethodEnabled="False" Width="284" />
限制输入的字符
<TextBox Name="TBoxIp" PreviewTextInput="TBoxIp_PreviewTextInput" InputMethod.IsInputMethodEnabled="False" Width="284" />
private void TBoxIp_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
Regex re = new Regex("[^0-9.-]+");
e.Handled = re.IsMatch(e.Text);
}