예제 #1
0
        protected override void SetErrors(object target, IList <object> errors, IDataContext context)
        {
#if WINDOWS_UWP
            var control = target as Control;
            if (control != null)
            {
                VisualStateManager.GoToState(control, errors.Count == 0 ? "Valid" : "Invalid", true);
            }
#else
            var element = target as FrameworkElement;
            if (element != null)
            {
                ValidationBinder.SetErrors(element, errors);
            }
#endif
        }
예제 #2
0
        /// <summary>
        ///     Sets errors for binding target.
        /// </summary>
        /// <param name="target">The binding target object.</param>
        /// <param name="errors">The collection of errors</param>
        /// <param name="context">The specified context, if any.</param>
        protected override void SetErrors(object target, IList <object> errors, IDataContext context)
        {
            base.SetErrors(target, errors, context);

            var element = target as Element;

            if (element != null)
            {
                target = GetNativeView(element);
            }

            var frameworkElement = target as FrameworkElement;

            if (frameworkElement != null)
            {
                ValidationBinder.SetErrors(frameworkElement, errors);
            }
        }
예제 #3
0
        public static void SetErrors([NotNull] FrameworkElement element, [CanBeNull] IList <object> errors)
        {
            Should.NotBeNull(element, nameof(element));
            if (errors == null)
            {
                errors = Empty.Array <object>();
            }
            var binder = (ValidationBinder)element.GetValue(ErrorContainerProperty);

            if (binder == null)
            {
                if (errors.Count == 0)
                {
                    return;
                }
                binder = new ValidationBinder();
                element.SetValue(ErrorContainerProperty, binder);
                var binding = new System.Windows.Data.Binding(PropertyName)
                {
#if WPF && NET4
                    ValidatesOnDataErrors = true,
#else
                    ValidatesOnDataErrors       = false,
                    ValidatesOnNotifyDataErrors = true,
#endif
                    Mode = System.Windows.Data.BindingMode.OneWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
                    Source = binder,
                    ValidatesOnExceptions   = false,
                    NotifyOnValidationError = false,
#if WPF
                    NotifyOnSourceUpdated = false,
                    NotifyOnTargetUpdated = false
#endif
                };
                element.SetBinding(ErrorContainerProperty, binding);
            }
            binder._errors = errors;
            binder.OnErrorsChanged();
        }
        protected override void SetErrors(object target, IList <object> errors, IDataContext context)
        {
            var depObj = target as DependencyObject;

            if (depObj == null)
            {
                base.SetErrors(target, errors, context);
                return;
            }
#if WINDOWS_UWP || NETFX_CORE
            var control = depObj as Control;
            if (control != null)
            {
                VisualStateManager.GoToState(control, errors.Count == 0 ? "Valid" : "Invalid", true);
            }
#else
            var element = depObj as FrameworkElement;
            if (element != null)
            {
                ValidationBinder.SetErrors(element, errors);
            }
#endif
        }
 public static void Register(ValidationBinder binder)
 {
     binder.Register("firstname", FirstName);
     binder.Register("accountrolecode", AccountRoleCode);
     binder.Register("birthdate", BirthDate);
 }
 public static void Register(ValidationBinder binder)
 {
     binder.Register("productdescription", WriteInProduct);
     binder.Register("productid", ProductId);
 }
예제 #7
0
 public static void RegisterValidation(ValidationBinder binder)
 {
     binder.Register("record1id", ValidateRecord1Id);
     binder.Register("record1roleid", ValidateRecord1RoleId);
 }
 public static void RegisterValidation(ValidationBinder binder)
 {
     binder.Register("lastname", ValidateLastName);
 }
예제 #9
0
 public static void Register(ValidationBinder binder)
 {
     binder.Register("publishdate", PublishDate);
 }