public static bool CheckTimeFormat(FormControl formControl)
        {
            TextBox textBox = formControl.InputControl as TextBox;
            string  time    = textBox.Text;
            bool    match   = false;

            if (!string.IsNullOrEmpty(time))
            {
                string timePattern = @"^((0[0-9]|1[0-9]|2[0-3]):?[0-5][0-9])|24:?00$";
                match = Regex.IsMatch(time, timePattern);
            }

            if (match && IsFieldRequired(textBox) || !IsFieldRequired(textBox))
            {
                textBox.BorderThickness = new Thickness(1);
                textBox.BorderBrush     = formControl.BaseBorderColor;
                if (!string.IsNullOrEmpty(time) && time.Length == 4 && time[2] != ':')
                {
                    textBox.Text = time.Insert(2, ":");
                }
                return(true);
            }
            else
            {
                textBox.BorderThickness = new Thickness(2);
                textBox.BorderBrush     = formControl.RequiredBorderBrush;
                return(false);
            }
        }
 protected virtual void TextBox_DateChanged(object sender, TextChangedEventArgs e)
 {
     if (sender is TextBox textBox)
     {
         FormControl formControl = !string.IsNullOrEmpty(textBox.Name)
             ? _formControlsList.Find(x => textBox.Name == x.InputControl.Name)
             : _formControlsList.Find(x => GetTagIndex(x.InputControl) == GetTagIndex(textBox));
         string date  = textBox.Text.Trim();
         bool   match = false;
         if (!string.IsNullOrEmpty(date))
         {
             string datePattern = @"^(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\d\d$";//(0[1-9]|1[012])/(0[1-9]|1[0-9]|2[0-9]|3[01])/[1-2][0-9][0-9][0-9]
             match = Regex.IsMatch(date, datePattern);
         }
         if (match && IsFieldRequired(textBox) || !IsFieldRequired(textBox))
         {
             textBox.Text            = date;
             textBox.BorderThickness = new Thickness(1);
             textBox.BorderBrush     = formControl.BaseBorderColor;
         }
         else
         {
             textBox.BorderThickness = new Thickness(2);
             textBox.BorderBrush     = formControl.RequiredBorderBrush;
         }
     }
 }
        protected virtual void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox     textBox     = sender as TextBox;
            FormControl formControl = _formControlsList.FirstOrDefault(
                control => control.InputControl.Name == textBox.Name);

            if (IsFieldRequired(textBox) && string.IsNullOrEmpty(textBox.Text))
            {
                textBox.BorderThickness = new Thickness(2);
                textBox.BorderBrush     = formControl.RequiredBorderBrush;
            }
            else
            {
                textBox.BorderThickness = new Thickness(1);
                textBox.BorderBrush     = formControl.BaseBorderColor;
            }
        }
        protected virtual void AutoSuggestBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            AutoSuggestBox autoSuggestBox = sender as AutoSuggestBox;
            FormControl    formControl    = _formControlsList.FirstOrDefault(
                control => control.InputControl.Name == autoSuggestBox.Name);

            if (formControl != null)
            {
                if (IsFieldRequired(sender as Control) && string.IsNullOrEmpty(autoSuggestBox.Text))
                {
                    //autoSuggestBox.BorderThickness = new Thickness(2);
                    autoSuggestBox.BorderBrush = formControl.RequiredBorderBrush;
                }
                else
                {
                    //autoSuggestBox.BorderThickness = new Thickness(1);
                    autoSuggestBox.BorderBrush = formControl.BaseBorderColor;
                }
            }
        }