From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
HMI.UI/DpUtil/DataGridHelper.cs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/HMI.UI/DpUtil/DataGridHelper.cs b/HMI.UI/DpUtil/DataGridHelper.cs
new file mode 100644
index 0000000..bf113c1
--- /dev/null
+++ b/HMI.UI/DpUtil/DataGridHelper.cs
@@ -0,0 +1,56 @@
+锘縰sing System.Windows;
+using System.Windows.Controls;
+
+namespace HMI.UI.DpUtil
+{
+ public class DataGridHelper
+ {
+ public static DataGridColumn GetSelectedColumn(DataGrid obj)
+ {
+ return (DataGridColumn)obj.GetValue(SelectedColumnProperty);
+ }
+ public static void SetSelectedColumn(DataGrid obj, DataGridColumn value)
+ {
+ obj.SetValue(SelectedColumnProperty, value);
+ }
+ public static readonly DependencyProperty SelectedColumnProperty =
+ DependencyProperty.RegisterAttached("SelectedColumn", typeof(DataGridColumn), typeof(Grid),
+ new PropertyMetadata(null));
+
+ public static bool GetShowRowNumber(DependencyObject obj)
+ {
+ return (bool)obj.GetValue(ShowRowNumberProperty);
+ }
+ public static void SetShowRowNumber(DependencyObject obj, bool value)
+ {
+ obj.SetValue(ShowRowNumberProperty, value);
+ }
+
+ public static readonly DependencyProperty ShowRowNumberProperty =
+ DependencyProperty.RegisterAttached("ShowRowNumber", typeof(bool), typeof(DataGrid),
+ new PropertyMetadata(false, OnShowRowNumberChanged));
+
+ private static void OnShowRowNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is DataGrid grid)
+ {
+ if (e.Property == ShowRowNumberProperty)
+ {
+ if (((bool)e.NewValue))
+ {
+ grid.LoadingRow += Grid_LoadingRow;
+ }
+ else
+ {
+ grid.LoadingRow -= Grid_LoadingRow;
+ }
+ }
+ }
+ }
+
+ private static void Grid_LoadingRow(object sender, DataGridRowEventArgs e)
+ {
+ e.Row.Header = e.Row.GetIndex() + 1;
+ }
+ }
+}
--
Gitblit v1.9.1