InternalSetIsValid() static private method

static private InternalSetIsValid ( DependencyObject obj, bool value ) : void
obj System.Windows.DependencyObject
value bool
return void
Beispiel #1
0
        private void ValidationSourceUnloaded(object sender, RoutedEventArgs e)
        {
            if (sender is FrameworkElement)
            {
                ((FrameworkElement)sender).Unloaded -= ValidationSourceUnloaded;
            }
            else
            {
                ((FrameworkContentElement)sender).Unloaded -= ValidationSourceUnloaded;
            }

            // An unloaded control might be loaded again. Then we need to restore the validation errors.
            Tuple <object, ValidationError>[] errorsToRemove = errors.Where(err => err.Item1 == sender).ToArray();
            if (errorsToRemove.Any())
            {
                // It keeps alive because it listens to the Loaded event.
                new ValidationReloadedTracker(this, errorsToRemove.First().Item1, errorsToRemove.Select(x => x.Item2));

                foreach (Tuple <object, ValidationError> error in errorsToRemove)
                {
                    errors.Remove(error);
                }
            }

            ValidationHelper.InternalSetIsValid(owner, !errors.Any());
        }
 internal void AddErrors(object validationSource, IEnumerable <ValidationError> errors)
 {
     foreach (ValidationError error in errors)
     {
         AddError(validationSource, error);
     }
     ValidationHelper.InternalSetIsValid(owner, !errors.Any());
 }
 private void ErrorChangedHandler(object?sender, ValidationErrorEventArgs e)
 {
     if (e.Action == ValidationErrorEventAction.Added)
     {
         AddError(e.OriginalSource, e.Error);
     }
     else
     {
         var error = errors.FirstOrDefault(err => err.Item1 == e.OriginalSource && err.Item2 == e.Error);
         if (error != null)
         {
             errors.Remove(error);
         }
     }
     ValidationHelper.InternalSetIsValid(owner, !errors.Any());
 }