WPF TextBox 正则验证 大于等于0 小于等于1 的两位小数
2021-06-28 16:04
标签:property max res regex result wpf tostring textbox shared 正则:^(0\.\d+|[1-9][0-9]|1)$ TextBox绑定正则验证 用到的InventoryValidationRule类: public class InventoryValidationRule : ValidationRule public string InventoryPattern { get; set; } #endregion Properties #region Methods public override ValidationResult Validate( if (!(value is string)) string[] pieces = value.ToString().Split(‘,‘); foreach (string item in pieces) return ValidationResult.ValidResult; #endregion Methods WPF TextBox 正则验证 大于等于0 小于等于1 的两位小数 标签:property max res regex result wpf tostring textbox shared 原文地址:https://www.cnblogs.com/wangyan89smile/p/10037145.html
{
#region Properties
object value, CultureInfo cultureInfo)
{
if (InventoryPattern == null)
return ValidationResult.ValidResult;
return new ValidationResult(false,
"Inventory should be a comma separated list of model numbers as a string");
Regex m_RegEx = new Regex(InventoryPattern);
{
Match match = m_RegEx.Match(item);
if (match == null || match == Match.Empty)
return new ValidationResult(
false, "Invalid input format");
}
}
}
文章标题:WPF TextBox 正则验证 大于等于0 小于等于1 的两位小数
文章链接:http://soscw.com/essay/98959.html