HI ,
Im using the following example and it the list which should need to do the validation to is currently
inside the validation rules class but now I need to get it from outside and the list can be changed during RT,
how can I send the list from the view model to the validation rules class
public class Propeation : ValidationRule { private readonly List<String> validValues = new List<String> { "aa", "bb", "cc", "dd" }; public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if(value == null) return new ValidationResult(false, "The Field are not match"); string val = value.ToString().Trim(); bool isValid = !string.IsNullOrEmpty(val) && validValues.Contains(val); ValidationResult result = null; result = isValid ? new ValidationResult(true, null) : new ValidationResult(false, "The Field are not match"); return result; } }
<TextBox><TextBox.Text><Binding Path="NameOfViewModelPropery" UpdateSourceTrigger="PropertyChanged"><Binding.ValidationRules><local:PropertiesMapValidation ValidatesOnTargetUpdated="True"/></Binding.ValidationRules></Binding></TextBox.Text></TextBox>