开发者

Send parameter to custom validationrule

Is it possible t开发者_如何学运维o send a parameter to a custom validationrule?

My validationrule:

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;
    }
}

My property using the validationrule:

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

Any input is appreciated, thanks!


This might help you - http://michlg.wordpress.com/2010/01/29/wpf-custom-validationrule-with-an-additional-parameter/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜