private void CheckPass() { errorProvider1.Clear(); if (textBoxX1.Text == "") { SetError("不可空白。"); btn_save.Enabled = false; return; } if (ValidateEvent != null) { ReviseRuleNameEventArgs eventArg = GetArgs(); ValidateEvent.Invoke(this, eventArg); if (eventArg.Error == true) { SetError(eventArg.ErrorString); btn_save.Enabled = false; return; } else { btn_save.Enabled = true; } } }
/* * public bool ValidateControl() * { * var evt = new ValidateEvent(); * ValidateControlTree(evt); * ViewContext.ControllerContext.Application.NotifyOnValidate(evt); * return evt.Validations.All(x => x.IsValid); * } */ /* * private void ValidateControlTree(ValidateEvent evt) * { * OnValidate(evt); * foreach (var child in Children) * child.ValidateControlTree(evt); * } */ protected virtual void OnValidate(ValidateEvent evt) { var validate = Validate; if (validate != null) { validate(evt); } }
private void ValidateCommandExecuted(object sender, ExecutedRoutedEventArgs e) { if ((MainViewModel.Instance.Parameters.BaseParameters.AdminLogin == Login && MainViewModel.Instance.Parameters.BaseParameters.AdminPassword == Password) || TeacherModel.Login(Login, Password).Any()) { ValidateEvent?.Invoke(); } else { MessageBox.Show("Erreur d'authentification", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Returns the final value of the ValidateEventArgs.IsValid property. /// </summary> private bool RaiseEvent(ValidatorItem <T> validator_item) { ValidateEventArgs <T> e = new ValidateEventArgs <T>(validator_item.PropertyName); e.Remark = ""; ValidateEvent?.Invoke(this, _viewmodel, e); //if (validator_item.Control != null) //{ //FormField ff = VenturaVisualTreeHelper.FindParent<FormField>(validator_item.Control); if (validator_item.FormField != null) { validator_item.FormField.Remark = e.Remark; } //} return(e.IsValid); }
public virtual void Validate() { ValidateEvent?.Invoke(this, new LayerConstructEventArgs(this)); }