コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the ValidationSummary class.
 /// </summary>
 public ValidationSummary()
 {
     this.DefaultStyleKey = typeof(ValidationSummary);
     this._errors         = new ValidationItemCollection();
     this._validationSummaryItemDictionary = new Dictionary <string, ValidationSummaryItem>();
     this._displayedErrors           = new ValidationItemCollection();
     this._errors.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(this.Errors_CollectionChanged);
     this.Loaded           += new RoutedEventHandler(this.ValidationSummary_Loaded);
     this.IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.ValidationSummary_IsEnabledChanged);
     if (DesignerProperties.IsInDesignTool)
     {
         this.Errors.Add(new ValidationSummaryItem(resources.ValidationSummarySampleError, typeof(ValidationSummaryItem).Name, ValidationSummaryItemType.ObjectError, null, null));
         this.Errors.Add(new ValidationSummaryItem(resources.ValidationSummarySampleError, typeof(ValidationSummaryItem).Name, ValidationSummaryItemType.ObjectError, null, null));
         this.Errors.Add(new ValidationSummaryItem(resources.ValidationSummarySampleError, typeof(ValidationSummaryItem).Name, ValidationSummaryItemType.ObjectError, null, null));
     }
 }
コード例 #2
0
        /// <summary>
        /// Clears errors of the given source type
        /// </summary>
        /// <param name="errorType">The type of the error (Entity or Property)</param>
        internal void ClearErrors(ValidationSummaryItemType errorType)
        {
            // Clear entity errors
            ValidationItemCollection errorsToRemove = new ValidationItemCollection();

            foreach (ValidationSummaryItem error in this)
            {
                if (error != null && error.ItemType == errorType)
                {
                    errorsToRemove.Add(error);
                }
            }
            foreach (ValidationSummaryItem error in errorsToRemove)
            {
                this.Remove(error);
            }
        }