diff --git a/MainWindow.xaml b/MainWindow.xaml
index 224cb25..d1b7c84 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -71,7 +71,7 @@
-
@@ -98,7 +98,7 @@
-
@@ -168,9 +168,8 @@
-
+ Text="{Binding PRODUCT_CODE}" IsTextSearchEnabled="True" StaysOpenOnEdit="True"
+ BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" KeyDown="CP_PRODUCT_CODE_KeyUp">
@@ -178,14 +177,16 @@
-
+
-
+
@@ -198,7 +199,7 @@
diff --git a/UserClass/DataGridHelper.cs b/UserClass/DataGridHelper.cs
new file mode 100644
index 0000000..77d6a7e
--- /dev/null
+++ b/UserClass/DataGridHelper.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows;
+
+namespace formula_manage.UserClass
+{
+ public static class DataGridHelper
+ {
+ public static void SetRealTimeCommit(DataGrid dataGrid, bool isRealTime)
+ {
+ dataGrid.SetValue(RealTimeCommitProperty, isRealTime);
+ }
+
+ public static bool GetRealTimeCommit(DataGrid dataGrid)
+ {
+ return (bool)dataGrid.GetValue(RealTimeCommitProperty);
+ }
+
+ public static readonly DependencyProperty RealTimeCommitProperty =
+ DependencyProperty.RegisterAttached("RealTimeCommit", typeof(bool),
+ typeof(DataGridHelper),
+ new PropertyMetadata(false, RealTimeCommitCallBack));
+
+ private static void RealTimeCommitCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var dg = d as DataGrid;
+ if (dg == null)
+ return;
+ EventHandler ceHandler = delegate (object xx, DataGridCellEditEndingEventArgs yy)
+ {
+ var flag = GetRealTimeCommit(dg);
+ if (!flag)
+ return;
+ var cellContent = yy.Column.GetCellContent(yy.Row);
+ if (cellContent != null && cellContent.BindingGroup != null)
+ cellContent.BindingGroup.CommitEdit();
+ };
+ dg.CellEditEnding += ceHandler;
+ RoutedEventHandler eh = null;
+ eh = (xx, yy) =>
+ {
+ dg.Unloaded -= eh;
+ dg.CellEditEnding -= ceHandler;
+ };
+ dg.Unloaded += eh;
+ }
+ }
+}
diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs
index 61e6c75..2584feb 100644
--- a/ViewModel/MainWindowViewModel.cs
+++ b/ViewModel/MainWindowViewModel.cs
@@ -170,7 +170,7 @@ namespace formula_manage.ViewModel
{
DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event
{
- Interval = TimeSpan.FromSeconds(0.1)
+ Interval = TimeSpan.FromSeconds(0.5)
};
timer.Tick += Tick_Event;
timer.Start();
diff --git a/formula_manage.csproj b/formula_manage.csproj
index 1ddbfd4..1337f39 100644
--- a/formula_manage.csproj
+++ b/formula_manage.csproj
@@ -176,6 +176,7 @@
Login.xaml
+