From 2e54b439c64e0adbb7e010243c1f33aa5fc5f503 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 11 三月 2025 14:08:57 +0800
Subject: [PATCH] 完善程序; Merge branch 'master' of http://58.211.88.246:3600/r/WPF/WPFProject
---
HMI.UI/DpUtil/FormGroupHelper.cs | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/HMI.UI/DpUtil/FormGroupHelper.cs b/HMI.UI/DpUtil/FormGroupHelper.cs
index 21c314e..feda1f9 100644
--- a/HMI.UI/DpUtil/FormGroupHelper.cs
+++ b/HMI.UI/DpUtil/FormGroupHelper.cs
@@ -1,4 +1,5 @@
-锘縰sing Panuon.WPF.UI;
+锘縰sing HMI.Core.Util;
+using Panuon.WPF.UI;
using System.Windows;
using System.Windows.Controls;
@@ -21,15 +22,14 @@
new PropertyMetadata(false, (d, e) =>
{
if (!(d is FormGroup fg)) return;
- if ((bool)e.NewValue)
+ if ((bool)e.NewValue && !string.IsNullOrEmpty(fg.Header?.ToString()))
{
- var style = Application.Current.FindResource("RequiredInputFormGroupStyle") as Style;
- fg.Style = style;
+ var dataTemplate = Application.Current.FindResource("RequiredFormHeader") as DataTemplate;
+ fg.HeaderTemplate = dataTemplate;
}
else
{
- var style = Application.Current.FindResource("RequiredInputFormGroupStyle") as Style;
- fg.Style = style;
+ fg.HeaderTemplate = null;
}
}));
@@ -57,12 +57,14 @@
{
if (child is FormGroup fg)
{
+ fg.ValidateResult = ValidateResult.None;
+ fg.Message = null;
object content = fg.Content;
object value = GetValidateValue(content);
- if (value != null && GetIsRequired(fg) && string.IsNullOrEmpty(value.ToString()))
+ if (GetIsRequired(fg) && (value == null || string.IsNullOrEmpty(value.ToString())))
{
fg.ValidateResult = ValidateResult.Error;
- fg.Message = $"{fg.Header}涓嶈兘涓虹┖";
+ fg.Message = string.Format(LangUtil.Get("App.CantBeEmpty"), fg.Header);
res = false;
}
else
@@ -87,10 +89,11 @@
return elementCollection.Count > 0 ? GetValidateValue(elementCollection[0]) : null;
if (content is TextBox tb) return tb.Text;
if (content is CheckBox cb) return cb.IsChecked;
- if (content is ComboBox cBox) return cBox.Text;
+ if (content is ComboBox cBox) return cBox.SelectedValue;
if (content is Panel panel) return GetValidateValue(panel.Children);
if (content is NumberInput numberInput) return numberInput.Value;
+ if (content is PasswordBox passwordInput) return passwordInput.Password;
return null;
}
}
--
Gitblit v1.9.1