ValidationRules.AddDependentPropertyValidationRules.AddDependentProperty
Old forum URL: forums.lhotka.net/forums/t/7566.aspx
Frazer posted on Thursday, September 03, 2009
Chapter 17 states:
ValidationRules.AddDependentProperty(StartedProperty, EndedProperty, true);
This call to the
AddDependentProperty() method tells the business rules subsystem in CSLA .NET that any time the rules for the Started property are checked, the rules for Ended should be checked too, because the last parameter is true.
What happens if the last parameter is false? Am I correct that the this would cause the EndedProperty to be validated if the StartedProperty is changed but not vice versa?
Frazer
JonnyBee replied on Thursday, September 03, 2009
Hi,
Last perameter tells if this dependency is bidirectional, meaning:
false:
when StartedProperty is Changed - check rules for EndedProperty also
true:
when StartedProperty is Changed - check rules for EndedProperty also
when EndedProperty is Changed - check rules for StartedProperty also
Do not add:
ValidationRules.AddDependentProperty(StartedProperty, EndedProperty, false);
ValidationRules.AddDependentProperty(EndedProperty, StartedProperty, false);
as this vill make an infinite loop. If bidirectional use
ValidationRules.AddDependentProperty(StartedProperty, EndedProperty, true);
/jonnybee
Copyright (c) Marimer LLC