示例#1
0
        public static bool SetValidationHintToInvalid(this AdornerUIManager manager, BaseEdit edit, string text = "")
        {
            foreach (var element in manager.Elements)
            {
                if (element is ValidationHint validation)
                {
                    if (ReferenceEquals(validation.TargetElement, edit))
                    {
                        var oldText = validation.Properties.InvalidState.Text;
                        try
                        {
                            if (!string.IsNullOrWhiteSpace(text))
                            {
                                validation.Properties.InvalidState.Text = text;
                            }
                            validation.Properties.State = ValidationHintState.Invalid;
                        }
                        finally
                        {
                            validation.Properties.InvalidState.Text = oldText;
                        }


                        return(true);
                    }
                }
            }
            return(false);
        }
示例#2
0
 public static void SetValidationHintsToValid(this AdornerUIManager manager)
 {
     foreach (var element in manager.Elements)
     {
         if (element is ValidationHint validation)
         {
             validation.Properties.State = ValidationHintState.Valid;
         }
     }
 }
示例#3
0
 public static void CreateValidationHints(this AdornerUIManager manager, string text, params BaseEdit[] edits)
 {
     foreach (var edit in edits)
     {
         var hint = new ValidationHint
         {
             TargetElement = edit
         };
         hint.Properties.IndeterminateState.ShowBorder = DefaultBoolean.False;
         hint.Properties.ValidState.ShowBorder         = DefaultBoolean.False;
         hint.Properties.InvalidState.Text             = text;
         hint.Properties.InvalidState.HintLocation     = ValidationHintLocation.Right;
         manager.Elements.Add(hint);
     }
 }