0
在ComboBoxNotEmptyValidationRule
类使用Int32.Parse
后后的错误,我得到一个错误:WPF - 使用Int32.Parse
Input string was not in a correct format.
当我添加到XAML:
<local:ComboBoxNotEmptyValidationRule x:Name="Number" ValidatesOnTargetUpdated="True"/>
计划是normaly运行,这walidation工作正常。在设计窗口我没有任何内容,只有FormatException: Input string was not in a correct format.
消息。当我在XAML中评论这一行时,一切都很好。
class ComboBoxNotEmptyValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
int str = -1;
str = Int32.Parse(value as string);
if (str > 0)
{
if (str > 0)
return ValidationResult.ValidResult;
}
return new ValidationResult(false, "please fill required field");
}
}
你能显示更多的代码吗?我们不知道“ComboBoxNotEmptyValidationRule”是什么,等等。 – 2013-02-08 18:34:28
@ Jeff-Meadows我添加了这个类。 – user1031034 2013-02-08 18:46:49
你确定值是字符串类型吗?价值的内容是什么? – LPL 2013-02-08 19:02:18