/// <summary>
        /// Cleans up.
        /// </summary>
        private void CleanUp()
        {
            var objects = new List <object>();

            lock (_objectValidationLock)
            {
                objects.AddRange(_objectValidation.Keys);
            }

            foreach (object obj in objects)
            {
                if (obj is IEnumerable)
                {
                    RemoveObjectsFromWatchList(obj as IEnumerable);
                }
                else if (obj is INotifyPropertyChanged)
                {
                    RemoveObjectFromWatchList(obj);
                }
            }

            _objectValidation.Clear();

#if NET
            if (_infoBarMessageControl != null)
            {
                _infoBarMessageControl.UnsubscribeWarningAndErrorValidator(this);
                _infoBarMessageControl = null;
            }
#endif
        }
        /// <summary>
        /// Initializes this instance. Loads all the errors and warnings that were added when the control was not yet loaded.
        /// </summary>
        private void Initialize()
        {
#if NET
            if (AutomaticallyRegisterToInfoBarMessageControl)
            {
                //_infoBarMessageControl = this.FindLogicalAncestorByType<InfoBarMessageControl>();
                _infoBarMessageControl = this.FindLogicalOrVisualAncestorByType <InfoBarMessageControl>();
                if (_infoBarMessageControl != null)
                {
                    _infoBarMessageControl.SubscribeWarningAndErrorValidator(this);
                }
            }
#endif

            var source = Source;
            if (source != null)
            {
                UpdateSource(null, source);
            }
        }
        /// <summary>
        /// Initializes this instance. Loads all the errors and warnings that were added when the control was not yet loaded.
        /// </summary>
        private void Initialize()
        {
#if NET || NETCORE
            if (AutomaticallyRegisterToInfoBarMessageControl)
            {
                //_infoBarMessageControl = this.FindLogicalAncestorByType<InfoBarMessageControl>();
                _infoBarMessageControl = this.FindLogicalOrVisualAncestorByType <InfoBarMessageControl>();
                if (_infoBarMessageControl != null)
                {
                    _infoBarMessageControl.SubscribeWarningAndErrorValidator(this);
                }
            }
#endif

            var source = Source;
            if (source != null)
            {
                UpdateSource(null, source);

                // Since we are initializing, we *must* force raising changes, fixes https://github.com/Catel/Catel/issues/1670
                RaiseEventsForDifferences(source, null, CreateValidationData(source, null, null));
            }
        }
        /// <summary>
        /// Cleans up.
        /// </summary>
        private void CleanUp()
        {
            var objects = new List<object>();

            lock (_objectValidationLock)
            {
                objects.AddRange(_objectValidation.Keys);
            }

            foreach (object obj in objects)
            {
                if (obj is IEnumerable)
                {
                    RemoveObjectsFromWatchList(obj as IEnumerable);
                }
                else if (obj is INotifyPropertyChanged)
                {
                    RemoveObjectFromWatchList(obj);
                }
            }

            _objectValidation.Clear();

#if !NETFX_CORE
            if (_infoBarMessageControl != null)
            {
                _infoBarMessageControl.UnsubscribeWarningAndErrorValidator(this);
                _infoBarMessageControl = null;
            }
#endif
        }
        /// <summary>
        /// Initializes this instance. Loads all the errors and warnings that were added when the control was not yet loaded.
        /// </summary>
        private void Initialize()
        {
#if !NETFX_CORE
            if (AutomaticallyRegisterToInfoBarMessageControl)
            {
                //_infoBarMessageControl = this.FindLogicalAncestorByType<InfoBarMessageControl>();
                _infoBarMessageControl = this.FindLogicalOrVisualAncestorByType<InfoBarMessageControl>();
                if (_infoBarMessageControl != null)
                {
                    _infoBarMessageControl.SubscribeWarningAndErrorValidator(this);
                }
            }
#endif

            var source = Source;
            if (source != null)
            {
                UpdateSource(null, source);
            }
        }