Validation rules not firing

Validation rules not firing

Old forum URL:

Calin posted on Wednesday, May 26, 2010


I am having a little trouble with validation rules not firing on a BusinessBase object, here is my AddBusinessRules method:

        protected override void AddBusinessRules()


 ValidationRules.AddRule(CustomCommonRules.UniqueCombination<CheckProductPriceVendorAndPriceGroup>, IdProperty, VendorIdProperty, PriceGroupIdProperty);


Now if I change the PriceGroupId property the rules don't fire.

What I did is to override the OnPropertyChanged and fire the rules like ValidationRules.CheckRules, but this gives me a different error.

"Cannot change ObservableCollection during a CollectionChanged or PropertyChanged event."

Any idea on how can I work around this ?


Thank you,

RockfordLhotka replied on Wednesday, May 26, 2010

Your code is adding an async rule to the IdProperty. You need to add the rule to PriceGroupId, or make PriceGroupId a dependent property on IdProperty if you want the rule to run when PriceGroupId is changed.

Calin replied on Friday, May 28, 2010

Thank you, this did the trick.

Copyright (c) Marimer LLC