public override FrameworkElement CreateControl(FormItemContext context)
        {
            PasswordBox tb = new PasswordBox();

            CustomValidation.SetValidationCallback(tb, () =>
            {
                string errMsg = null;
                if (tb.Password == null ||
                    tb.Password.Length < 6)
                {
                    errMsg = "密码强度不够";
                }
                CustomValidation.SetValidationError(tb, errMsg);
                return errMsg;
            });

            tb.PasswordChanged += (s, e) =>
            {
                CustomValidation.ForceValidation(tb);
                context.SetValueToBindedProperty(tb.Password);
            };

            StyleHelper.ApplyStyle(tb, "editctl_pwd");
            return tb;
        }
Example #2
0
        public override FrameworkElement CreateControl(FormItemContext context)
        {
            PasswordBox tb = new PasswordBox();

            CustomValidation.SetValidationCallback(tb, () =>
            {
                string errMsg = null;
                if (tb.Password == null ||
                    tb.Password.Length < 6)
                {
                    errMsg = "密码强度不够";
                }
                CustomValidation.SetValidationError(tb, errMsg);
                return(errMsg);
            });

            tb.PasswordChanged += (s, e) =>
            {
                CustomValidation.ForceValidation(tb);
                context.SetValueToBindedProperty(tb.Password);
            };

            StyleHelper.ApplyStyle(tb, "editctl_pwd");
            return(tb);
        }