瀏覽代碼

Fixed internal syncfusion exception when refreshing items source inside of event handler.

Kenric Nugteren 1 年之前
父節點
當前提交
1e4dea2ccb

+ 3 - 6
inabox.wpf/DynamicGrid/DynamicGrid.cs

@@ -1191,7 +1191,7 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
                         MasterData = table;
                         Dispatcher.Invoke(() =>
                         {
-                            ProcessData(reloadcolumns, reloaddata);
+                            ProcessData();
                             DoAfterRefresh();
                             bRefreshing = false;
                             IsReady = true;
@@ -1202,7 +1202,7 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
         }
         else
         {
-            ProcessData(reloadcolumns, reloaddata);
+            ProcessData();
             DoAfterRefresh();
             bRefreshing = false;
             IsReady = true;
@@ -1261,7 +1261,7 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
     }
 
 
-    private void ProcessData(bool reloadcolumns, bool reloaddata)
+    private void ProcessData()
     {
         Data.Columns.Clear();
         Data.Setters.Clear();
@@ -1446,11 +1446,8 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
         if (!SelectedRows.Any())
             return;
 
-        var sel = SelectedRows.ToArray();
         if (AddEditClick(SelectedRows))
         {
-            InvalidateGrid();
-            SelectedRows = sel;
             SelectItems(SelectedRows);
         }
     }

+ 4 - 0
inabox.wpf/DynamicGrid/UIComponent/DynamicGridTreeUIComponent.cs

@@ -188,7 +188,11 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
 
     private void _tree_CellDoubleTapped(object? sender, TreeGridCellDoubleTappedEventArgs e)
     {
+        _tree.Dispatcher.BeginInvoke(() =>
+        {
+            // This needs to happen outside the event handler, because the items source for the tree view might change during this method, and that causes an internal exception in Syncfusion. We need to finish the event before resetting the items source.
         Parent.DoubleClickCell(GetRowFromIndex(e.RowColumnIndex.RowIndex), GetColumn(e.RowColumnIndex.ColumnIndex));
+        });
     }
 
     private void _tree_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)