private void View_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(Label): this.Label = AtomForm.GetLabel(Content); UpdateCell(); break; case nameof(LabelColor): this.LabelColor = AtomForm.GetLabelColor(Content); UpdateCell(); break; case nameof(Error): this.Error = AtomForm.GetError(Content); UpdateCell(); break; case nameof(Description): this.Description = AtomForm.GetDescription(Content); UpdateCell(); break; case nameof(IsRequired): this.IsRequired = AtomForm.GetIsRequired(Content); UpdateCell(); break; case nameof(Content): UpdateCell(); break; } }
/// <summary> /// /// </summary> /// <param name="view"></param> public void BindView(View view) { this.Content = view; view.PropertyChanged += View_PropertyChanged; Label = AtomForm.GetLabel(view); this.LabelColor = AtomForm.GetLabelColor(view); this.Error = AtomForm.GetError(view); this.Description = AtomForm.GetDescription(view); this.IsRequired = AtomForm.GetIsRequired(view); this.UpdateCell(); }
/// <summary> /// /// </summary> /// <param name="propertyName"></param> protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == "IsFocused") { if (!this.IsFocused) { // we just lost the focus?? // lets validate this textbox... if (AtomForm.GetError(this) != null) { AtomValidationRule.Validate(this); } } } }
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> /// /// </summary> /// <param name="view"></param> public void BindView(View view) { this.Content = view; if (view == null) { return; } view.SetBinding(BindingContextProperty, new Binding { Path = "BindingContext", Source = this.Form }); view.PropertyChanged += View_PropertyChanged; Label = AtomForm.GetLabel(view); this.LabelColor = AtomForm.GetLabelColor(view); this.Error = AtomForm.GetError(view); this.Description = AtomForm.GetDescription(view); this.IsRequired = AtomForm.GetIsRequired(view); this.SetBinding(IsVisibleProperty, new Binding { Path = "IsVisible", Source = view }); this.lastDisposable.SetTarget(AtomFieldRenderer.BindKeyboardActions(view)); this.UpdateCell(); }