private static void OnTargetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement  oldElement = e.OldValue as FrameworkElement;
            ValidationSummary vs         = d as ValidationSummary;
            EventHandler <ValidationErrorEventArgs> handler = new EventHandler <ValidationErrorEventArgs>(vs.Target_BindingValidationError);

            if (vs._registeredParent != null)
            {
                vs._registeredParent.BindingValidationError -= handler;
                vs._registeredParent = null;
            }
            if (oldElement != null)
            {
                oldElement.BindingValidationError -= handler;
            }
            FrameworkElement newElement = e.NewValue as FrameworkElement;

            if (newElement != null)
            {
                newElement.BindingValidationError += handler;
            }

            // Clear the old property binding errors
            vs._errors.ClearErrors(ValidationSummaryItemType.PropertyError);
            vs.UpdateDisplayedErrors();
        }
        private static void OnFilterPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ValidationSummary vs = d as ValidationSummary;

            if (vs != null)
            {
                vs.UpdateDisplayedErrors();
            }
        }
        /// <summary>
        /// When one of the input controls has its ShowErrorsInSummary property changed, we have to go through all the ValidationSummaries on the page and update them
        /// </summary>
        /// <param name="parent">The parent ValidationSummary</param>
        private static void UpdateDisplayedErrorsOnAllValidationSummaries(DependencyObject parent)
        {
            if (parent == null)
            {
                return;
            }

            ValidationSummary vs = parent as ValidationSummary;

            if (vs != null)
            {
                vs.UpdateDisplayedErrors();
                return;
            }

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(parent, i);
                UpdateDisplayedErrorsOnAllValidationSummaries(child);
            }
        }