From 1afe548ac40cc7f975917ef9bf2e156595cf81f3 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 16 四月 2026 08:58:04 +0800
Subject: [PATCH] 优化;

---
 HMI.UI/DpUtil/FormGroupHelper.cs |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/HMI.UI/DpUtil/FormGroupHelper.cs b/HMI.UI/DpUtil/FormGroupHelper.cs
index bdfd5bd..bc45159 100644
--- a/HMI.UI/DpUtil/FormGroupHelper.cs
+++ b/HMI.UI/DpUtil/FormGroupHelper.cs
@@ -1,5 +1,6 @@
 锘縰sing 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;

--
Gitblit v1.9.1