Esempio n. 1
0
        private static void ValidationScopeChanged(DependencyObject source, DependencyPropertyChangedEventArgs args)
        {
            ValidationScope oldScope = args.OldValue as ValidationScope;

            if (oldScope != null)
            {
                oldScope.ScopeElement.BindingValidationError -= oldScope.ScopeElement_BindingValidationError;
                oldScope.ScopeElement = null;
            }

            FrameworkElement scopeElement = source as FrameworkElement;

            if (scopeElement == null)
            {
                throw new ArgumentException(string.Format(
                                                "'{0}' is not a valid type.ValidationScope attached property can only be specified on types inheriting from FrameworkElement.",
                                                source));
            }

            ValidationScope newScope = (ValidationScope)args.NewValue;

            newScope.ScopeElement = scopeElement;
            newScope.ScopeElement.BindingValidationError += newScope.ScopeElement_BindingValidationError;
        }
Esempio n. 2
0
 public static void SetValidationScope(DependencyObject obj, ValidationScope value)
 {
     obj.SetValue(ValidationScopeProperty, value);
 }
Esempio n. 3
0
 public static void SetValidationScope(DependencyObject obj, ValidationScope value)
 {
     obj.SetValue(ValidationScopeProperty, value);
 }