소스 검색

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

Kenric Nugteren 1 년 전
부모
커밋
1e4dea2ccb
2개의 변경된 파일7개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 6
      inabox.wpf/DynamicGrid/DynamicGrid.cs
  2. 4 0
      inabox.wpf/DynamicGrid/UIComponent/DynamicGridTreeUIComponent.cs

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

@@ -1191,7 +1191,7 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
                         MasterData = table;
                         MasterData = table;
                         Dispatcher.Invoke(() =>
                         Dispatcher.Invoke(() =>
                         {
                         {
-                            ProcessData(reloadcolumns, reloaddata);
+                            ProcessData();
                             DoAfterRefresh();
                             DoAfterRefresh();
                             bRefreshing = false;
                             bRefreshing = false;
                             IsReady = true;
                             IsReady = true;
@@ -1202,7 +1202,7 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
         }
         }
         else
         else
         {
         {
-            ProcessData(reloadcolumns, reloaddata);
+            ProcessData();
             DoAfterRefresh();
             DoAfterRefresh();
             bRefreshing = false;
             bRefreshing = false;
             IsReady = true;
             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.Columns.Clear();
         Data.Setters.Clear();
         Data.Setters.Clear();
@@ -1446,11 +1446,8 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
         if (!SelectedRows.Any())
         if (!SelectedRows.Any())
             return;
             return;
 
 
-        var sel = SelectedRows.ToArray();
         if (AddEditClick(SelectedRows))
         if (AddEditClick(SelectedRows))
         {
         {
-            InvalidateGrid();
-            SelectedRows = sel;
             SelectItems(SelectedRows);
             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)
     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));
         Parent.DoubleClickCell(GetRowFromIndex(e.RowColumnIndex.RowIndex), GetColumn(e.RowColumnIndex.ColumnIndex));
+        });
     }
     }
 
 
     private void _tree_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
     private void _tree_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)