Switching between RuleSets and DataBinding

Switching between RuleSets and DataBinding

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

andrew_m75 posted on Wednesday, November 30, 2011


There is a BO that is bound to WPF form. This BO has two RuleSet. Switching between them takes on a certain algorithm. But switching between sets did not appear on the form. In other words, if the business property is in one RuleSet does not pass validation,  is displayed in the control. After changing the RuleSet, property is validated, but control displays the old information, that property is not valid.

What should I do to the form displays current information about data validation?

JonnyBee replied on Wednesday, November 30, 2011


RuleSets are not supposed to be used on objects that are active in DataBinding.

In order to make this wrk you need to add a similar CheckRules method to your BO and call OnPropertyChanged for all registered properties in order to notify UI of changes to Properties and validation.

/// <summary>
/// Checks all rules in the object and notifies UI of properties that may have changed.
/// </summary>
protected virtual void CheckRules()
if (ApplicationContext.PropertyChangedMode == ApplicationContext.PropertyChangedModes.Windows)
foreach (var name in this.FieldManager.GetRegisteredProperties())

andrew_m75 replied on Wednesday, November 30, 2011

Thank you, Jonny. It works!

Copyright (c) Marimer LLC