开发者

Send parameter to custom validationrule

开发者 https://www.devze.com 2023-02-25 00:16 出处:网络
Is it possible t开发者_如何学运维o send a parameter to a custom validationrule? My 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

精彩评论

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