Esempio n. 1
0
 private void SetSourceFromProperty()
 {
     if (FrameworkElementService.GetIsFirstVisit(this))
     {
         var expression = this.GetBindingExpression(PropertyProperty);
         if (expression != null && this.Source == null)
         {
             this.SetValue(Validator.SourceProperty, expression.DataItem as FrameworkElement);
         }
     }
 }
Esempio n. 2
0
        private static void TriggerElementPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Validator validator = d as Validator;

            if (FrameworkElementService.GetIsFirstVisit(validator.TriggerElement))
            {
                validator.RegisterTriggerValidationEvent();
                FrameworkElementService.SetIsFirstVisit(validator.TriggerElement, false);
            }

            ValidationService.GetValidators(validator.TriggerElement).Add(validator);
        }
Esempio n. 3
0
        protected static void ValidPropertyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Validator validator = d as Validator;

            validator.SetSourceFromProperty();

            if (validator.HasSourceContext)
            {
                UIThread.BeginInvoke(() =>
                {
                    var isValid       = validator.IsValid;
                    validator.IsValid = validator.InnerValidateWithError();
                    if (!isValid && !validator.IsValid && !FrameworkElementService.GetIsFirstVisit(validator))
                    {
                        validator.GapValidate();
                    }
                }, DispatcherPriority.Normal);
            }
            else
            {
                validator.IsValid = true;
            }
            FrameworkElementService.SetIsFirstVisit(validator, false);
        }