开发者

Can VAB Self-Validation Fire with Data Binding?

During WPF data binding, the validation rules are invoked, and the UI is properly updated to show validation errors. I would like the self-validation to be invoked during data binding as well. Is this possible?

If I explicitly validate the class in code, I see the self-validation error. However, the self-validation does not execute during data binding.

The class:

[HasSelfValidation]
public class CellStartSetting : EntityBase

The property:

[RangeValidator(typeof(decimal), "0", RangeBoundaryType.Inclusive, "360", RangeBoundaryType.Inclusive)]
public decimal? DelayTimeInSeconds
开发者_JS百科

The self-validation (this is garbage test code, so ignore the actual test):

[SelfValidation]
public void DelayTimeDecimalPlaces(ValidationResults validationResults)
{
    if (this.DelayTimeInSeconds == 4)
    {
        validationResults.AddResult(new ValidationResult("4 no good", this, "Four", null, null));
    }
}


I think I found my answer. This can't be done.

From http://msdn.microsoft.com/en-us/library/ff953182%28v=PandP.50%29.aspx:

Self-validation cannot be used with the UI validation integration features for Windows Forms, WPF, or ASP.NET.

Crap.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜