Sfoglia il codice sorgente

Allowed for customising the editor of Grid Columns, by usign the eidtor on the column, rather than the property.

Kenric Nugteren 10 mesi fa
parent
commit
72ce490e0b

+ 5 - 0
inabox.wpf/DynamicGrid/DynamicGrid.cs

@@ -1622,6 +1622,11 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
         AfterLoad(editor, items);
     }
 
+    BaseEditor IDynamicGridUIComponentParent<T>.CustomiseEditor(DynamicGridColumn column, BaseEditor editor)
+    {
+        return editor.CloneEditor();
+    }
+
     private void DoCustomiseEditor(IDynamicEditorForm sender, object[] items, DynamicGridColumn column, BaseEditor editor)
     {
         CustomiseEditor((T[])items, column, editor);

+ 2 - 1
inabox.wpf/DynamicGrid/UIComponent/DynamicGridGridUIComponent.cs

@@ -1253,7 +1253,8 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
                 var cellstyle = new Style();
                 if (Parent.IsDirectEditMode())
                 {
-                    if (prop.Editor is null || !prop.Editor.Editable.IsDirectEditable())
+                    var editor = Parent.CustomiseEditor(column, column.Editor);
+                    if (editor is null || !editor.Editable.IsDirectEditable())
                     {
                         cellstyle.Setters.Add(new Setter(Control.BackgroundProperty,
                             new Binding()

+ 2 - 1
inabox.wpf/DynamicGrid/UIComponent/DynamicGridTreeUIComponent.cs

@@ -1106,7 +1106,8 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
                 var cellstyle = new Style();
                 if (Parent.IsDirectEditMode())
                 {
-                    if (prop.Editor is null || !prop.Editor.Editable.IsDirectEditable())
+                    var editor = Parent.CustomiseEditor(column, column.Editor);
+                    if (editor is null || !editor.Editable.IsDirectEditable())
                     {
                         cellstyle.Setters.Add(new Setter(Control.BackgroundProperty,
                             new SolidColorBrush(Colors.WhiteSmoke)));

+ 2 - 0
inabox.wpf/DynamicGrid/UIComponent/IDynamicGridUIComponent.cs

@@ -29,6 +29,8 @@ public interface IDynamicGridUIComponentParent<T> : IDynamicGrid<T>
 
     void LoadColumnsMenu(ContextMenu menu);
 
+    BaseEditor CustomiseEditor(DynamicGridColumn column, BaseEditor editor);
+
     void DoubleClickCell(CoreRow? row, DynamicColumnBase? column);
     void ExecuteActionColumn(DynamicActionColumn column, CoreRow[]? rows);
     void OpenColumnMenu(DynamicColumnBase column);