alielie
2025-11-25 006c98e5650b530e5220f279c1e803fefe69d40d
HMI.UI/DpUtil/FormGroupHelper.cs
@@ -1,5 +1,6 @@
using HMI.Core.Util;
using Panuon.WPF.UI;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
@@ -49,7 +50,7 @@
            DependencyProperty.RegisterAttached("ValidateMethod", typeof(ValidateMethodDelegate), typeof(FormGroupHelper),
            new PropertyMetadata(null));
        public static bool ValidateForm(StackPanel fgPanel)
        public static bool ValidateForm(StackPanel fgPanel, Dictionary<string, object> values = null)
        {
            if (fgPanel.Children == null) return true;
            bool res = true;
@@ -57,6 +58,7 @@
            {
                if (child is FormGroup fg)
                {
                    string fgName = fg.Name;
                    if (fg.Visibility != Visibility.Visible)
                    {
                        ClearValue(fg);
@@ -64,8 +66,17 @@
                    }
                    fg.ValidateResult = ValidateResult.None;
                    fg.Message = null;
                    object content = fg.Content;
                    object value = GetValidateValue(content);
                    object value;
                    if (values != null && values.ContainsKey(fgName))
                    {
                        value = values[fgName];
                    }
                    else
                    {
                        object content = fg.Content;
                        value = GetValidateValue(content);
                    }
                    if (GetIsRequired(fg) && (value == null || string.IsNullOrEmpty(value.ToString())))
                    {
                        fg.ValidateResult = ValidateResult.Error;