Note that there are some explanatory texts on larger screens.

plurals
  1. PODual NHibernate Class Level Validators Issue
    text
    copied!<p>I'm using WPF and I've got an Entity bound to a series of controls. The entity is decorated with two class level validators as follows:</p> <pre><code>[ExampleValidator1, ExampleValidator2] public class Entity </code></pre> <p>An Entity has a series of fields of which not all are always shown, dependent on the selection from combo box. A validator exists for each of these selections, if the "type" of entity does not match a particular validator that validator returns true and obviously the correct validator will validate the actual fields as follows:</p> <pre><code>public bool IsValid(object value, IConstraintValidatorContext constraintValidatorContext) { constraintValidatorContext.DisableDefaultError(); var allPropertiesValid = true; var entity= (Entity)value; if (supplier.ParticularEntityType) { return true; } if (String.IsNullOrEmpty(entity.Name) || entity.Name.Length &gt; 50) { constraintValidatorContext.AddInvalid&lt;Entity, string&gt;("must be 50 or shorter and not empty", x =&gt; x.Name); allPropertiesValid = false; } </code></pre> <p>and the XAML is as follows:</p> <pre><code> &lt;TextBox Grid.Row="0" Grid.Column="3"&gt; &lt;TextBox.Text&gt; &lt;Binding Path="Entity.Name" UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True"&gt; &lt;/Binding&gt; &lt;/TextBox.Text&gt; &lt;/TextBox&gt; </code></pre> <p>Obviously I get the nice pretty red box and tool tips informing users of the validation requirements.</p> <p>My issue is that when the selection in the combobox is changed, the red highlighting persists (becomes a small red square when a control is hidden). Could someone direct me the right way please!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload