/// <summary> /// Validates the specified properties. /// </summary> /// <param name="propertyNames">The property names.</param> public void Validate(params string[] propertyNames) { var a = ValidationResults.Select(e => e.PropertyName).Distinct(); if (Validator == null) { ValidationResults = ValidationResults.Except(propertyNames).ToList(); } else { var validationSelector = propertyNames.Any() ? ValidatorOptions.ValidatorSelectors.MemberNameValidatorSelectorFactory(propertyNames) : ValidatorOptions.ValidatorSelectors.DefaultValidatorSelectorFactory(); var validationContext = new ValidationContext(this, new PropertyChain(), validationSelector); var results = Validator.Validate(validationContext).Errors; if (propertyNames.Length == 0) { ValidationResults = results; } else { ValidationResults = ValidationResults.Except(propertyNames).Concat(results).ToList(); } } OnPropertyChanged(nameof(ValidationResults)); var b = ValidationResults.Select(e => e.PropertyName).Distinct(); foreach (var propertyName in a.Concat(b).Distinct()) { OnErrorsChanged(propertyName); } }