PropertyHasChanged( "" ) and ValidationRules bug?

PropertyHasChanged( "" ) and ValidationRules bug?

Old forum URL: forums.lhotka.net/forums/t/1946.aspx


ajj3085 posted on Monday, December 11, 2006

Hi,

Its been suggested to use String.Empty to raise a property change event for an unknown property.   First, is PropertyHasChanged( "" ) supposed to raise an unknown property changed event?

If it is, it looks like there may be a bug with ValidationRules.CheckRules.  I would think that PropertyHasChanged( "" ) would cause all rulse to be rechecked, but the current implementation is that none of the rules are checked (because the property "" doesn't ever have any rules associated with it).

Andy

xal replied on Monday, December 11, 2006

I'm not sure it's a good idea for PropertyHasChanged( "" ) to validate all rules. Perhaps all you want is the listening bs to refresh all data, but not necesarily re-run all your validation methods because that could be expensive in some scenarios. If that is what you need, why not a combo of ValidationRules.CheckRules() & PropertyHasChanged("")? (I know I'm stating the obvious).

Andrés


RockfordLhotka replied on Monday, December 11, 2006

There's a method in BusinessBase you should call to indicate that an unknown property (or all properties) has changed. I don't have time to look up that method name right now, but that method does raise PropertyChanged with no property name specified, causing the property data binding behavior. It does not interact with the validation rules subsystem at all - so you'd also need to call ValidationRules.CheckRules() to take care of that.

xal replied on Monday, December 11, 2006

Isn't it OnUnknownPropertyChanged?

Andrés

ajj3085 replied on Monday, December 11, 2006

Fair enough.  It just seemed to me that PropertyHasChanged( "" ) would do the same thing and also run the rules.  But if PropertyHasChanged shouldn't be called with "" or null, maybe it should raise an exception if it gets one of those as parameter values?

Copyright (c) Marimer LLC