static AtomDatePicker() { DefaultValidator = new AtomPropertyValidator { BindableProperty = ValueProperty, ValidationRule = AtomUtils.Singleton <AtomDateValidationRule>() }; }
static AtomComboBox() { DefaultValidator = new AtomPropertyValidator { BindableProperty = SelectedItemProperty, ValidationRule = AtomUtils.Singleton <AtomSelectionValidationRule>() }; }
private static void OnValidatorChanged(BindableObject bindable, object oldValue, object newValue) { AtomPropertyValidator v = newValue as AtomPropertyValidator; if (v == null) { return; } bindable.PropertyChanged += (s, e) => { var error = AtomForm.GetError(bindable); if (string.IsNullOrWhiteSpace(error)) { return; } if (e.PropertyName == v.BindableProperty?.PropertyName || e.PropertyName == v.Property) { AtomValidationRule.Validate(bindable as View); } }; }
/// <summary> /// Set Validator for bindable object /// </summary> /// <param name="bindable"></param> /// <param name="newValue"></param> public static void SetValidator(BindableObject bindable, AtomPropertyValidator newValue) { bindable.SetValue(ValidatorProperty, newValue); }