输入验证(允许数字和小数点)
// 输入验证(允许数字和小数点) private void NumberValidation(object sender, TextCompositionEventArgs e) { var textBox = (TextBox)sender; var newText = textBox.Text.Insert(textBox.CaretIndex, e.Text); e.Handled = !decimal.TryParse(newText, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out _); } PreviewTextInput=”NumberValidation”
继续阅读