示例#1
0
        /// <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;
        }
示例#2
0
        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;
            }
        }
示例#3
0
        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;
                }
            }
        }
示例#4
0
 /// <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));
 }