/// <summary> /// Sets the value of <see cref="MonitorBindingValidationErrorsBehavior.Target"/> property to <paramref name="element"/>. /// </summary> /// <param name="element">Element whose <see cref="FrameworkElement.BindingValidationError"/> event will be handled.</param> public static void MonitorBindingValidationErrors(FrameworkElement element) { var behavior = DependencyPropertyHelper.GetOrAddValue <MonitorBindingValidationErrorsBehavior>( element, MonitorBindingValidationErrorsBehaviorProperty); behavior.Target = element; }
private static void ToggleBackgroundPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var element = dependencyObject as Control; if (element != null) { MonitorBindingValidationErrors(element); var behavior = DependencyPropertyHelper.GetOrAddValue <ToggleBackgroundOnValidationBehavior>( element, ToggleBackgroundOnValidationBehaviorProperty); behavior.Target = element; behavior.ErrorBrush = e.NewValue as Brush; } }
private static void ShowToolTipPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var element = dependencyObject as FrameworkElement; if (element != null) { if ((bool)e.NewValue == true) { MonitorBindingValidationErrors(element); var behavior = DependencyPropertyHelper.GetOrAddValue <ShowToolTipOnValidationBehavior>( element, ShowToolTipOnValidationBehaviorProperty); behavior.Target = element; } } }
/// <summary> /// Gets the value of <see cref="ErrorsProperty"/> on <paramref name="dependencyObject"/>. /// </summary> /// <param name="dependencyObject">Element on which the <see cref="ErrorsProperty"/> property is attached.</param> /// <returns>Value of <see cref="ErrorsProperty"/>.</returns> public static ObservableCollection <ValidationError> GetErrors(DependencyObject dependencyObject) { return(DependencyPropertyHelper.GetOrAddValue <ObservableCollection <ValidationError> >(dependencyObject, ErrorsProperty)); }