Procházet zdrojové kódy

Tweak to UpdateRow to include InvalidateRow

Kenric Nugteren před 7 měsíci
rodič
revize
e5dd0c1ede

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

@@ -1283,10 +1283,14 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
             InvalidateRow(row);
     }
 
-    public void UpdateRow(CoreRow row, T obj)
+    public void UpdateRow(CoreRow row, T obj, bool invalidateRow = true)
     {
         ObjectToRow(obj, row);
         ObjectToRow(obj, _recordmap[row]);
+        if (invalidateRow)
+        {
+            InvalidateRow(row);
+        }
     }
 
     /// <summary>
@@ -1296,11 +1300,7 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
     {
         for(var i = 0; i < objs.Length; ++i)
         {
-            UpdateRow(rows[i], objs[i]);
-            if (invalidateRows)
-            {
-                InvalidateRow(rows[i]);
-            }
+            UpdateRow(rows[i], objs[i], invalidateRow: invalidateRows);
         }
     }
 

+ 10 - 4
inabox.wpf/DynamicGrid/UIComponent/DynamicGridGridUIComponent.cs

@@ -743,6 +743,12 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
     protected virtual FontStyle? GetCellFontStyle(CoreRow row, DynamicColumnBase column) => null;
     protected virtual FontWeight? GetCellFontWeight(CoreRow row, DynamicColumnBase column) => null;
 
+    protected virtual Style GetCellStyle(DynamicColumnBase column)
+    {
+        var style = new Style(typeof(GridCell));
+        return style;
+    }
+
     protected virtual Style GetHeaderCellStyle(DynamicColumnBase column)
     {
         var headStyle = new Style(typeof(GridHeaderCellControl));
@@ -1176,8 +1182,8 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
             newcol.FilterRowCellStyle = style;
 
             newcol.HeaderStyle = GetHeaderCellStyle(column);
-            
-            var cellstyle = new Style();
+
+            var cellstyle = GetCellStyle(column);
             AddCellStyleConverters(cellstyle, column, sColName);
             newcol.CellStyle = cellstyle;
 
@@ -1229,7 +1235,7 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
 
             newcol.HeaderStyle = GetHeaderCellStyle(column);
 
-            var cellstyle = new Style();
+            var cellstyle = GetCellStyle(column);
             AddCellStyleConverters(cellstyle, column, sColName);
             newcol.CellStyle = cellstyle;
 
@@ -1261,7 +1267,7 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
             
             newColumn.HeaderStyle = GetHeaderCellStyle(column);
 
-            var cellstyle = new Style();
+            var cellstyle = GetCellStyle(column);
             if (Parent.IsDirectEditMode())
             {
                 var editor = Parent.CustomiseEditor(column, column.Editor);