添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using MessageBox = MaxwellControl.Controls.MessageBox;
|
||||
|
||||
namespace MainShell.Common.ControlAttribute
|
||||
{
|
||||
public class NumericValidationRule : ValidationRule
|
||||
{
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
string strValue = value as string;
|
||||
if (string.IsNullOrEmpty(strValue))
|
||||
{
|
||||
// 空值是允许的,如果需要必填,则返回 new ValidationResult(false, "不能为空");
|
||||
return new ValidationResult(false, "不能为空");
|
||||
}
|
||||
|
||||
// 尝试将字符串转换为double
|
||||
if (double.TryParse(strValue, out _))
|
||||
{
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ValidationResult(false, "请输入有效的数字。");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user