将参数发送到自定义validationrule

时间:2011-04-14 11:17:55

标签: c# wpf validation binding

是否可以将参数发送到自定义验证规则?

我的验证规则:

public class CustomTypeSelectedRule : IValidationRule
{
    public ValidationResult Validate(object input)
    {
        // Here I need an extra value from the class calling
        // the validation rule.

        return ValidationResult.Success;
    }
}

我的属性使用validationrule:

[ContractValidation(typeof(ValidationRules.CustomTypeSelectedRule))]
public int CustomType
{
    get
    {
        return this.customType;
    }
    set
    {
        this.customType = value;
    }
}

感谢任何意见,谢谢!

1 个答案:

答案 0 :(得分:1)