Selaa lähdekoodia

Fix to duplicate event handlers

Kenric Nugteren 7 kuukautta sitten
vanhempi
commit
53af830f37
1 muutettua tiedostoa jossa 7 lisäystä ja 4 poistoa
  1. 7 4
      inabox.wpf/DynamicGrid/DynamicEditorGrid.xaml.cs

+ 7 - 4
inabox.wpf/DynamicGrid/DynamicEditorGrid.xaml.cs

@@ -381,6 +381,8 @@ public partial class DynamicEditorGrid : UserControl, IDynamicEditorHost
             {
                 editor.Configure();
                 editor.Loaded = true;
+
+                editor.OnEditorValueChanged += EditorValueChanged;
             }
         }
 
@@ -465,9 +467,12 @@ public partial class DynamicEditorGrid : UserControl, IDynamicEditorHost
 
                 var bLoaded = editor.Loaded;
                 editor.Loaded = false;
-                if (changededitors != null && changededitors.ContainsKey(columnname))
+                if (changededitors != null)
                 {
-                    editor.SetValue(columnname, changededitors[columnname]);
+                    if (changededitors.TryGetValue(columnname, out var value))
+                    {
+                        editor.SetValue(columnname, value);
+                    }
                 }
                 else
                 {
@@ -486,8 +491,6 @@ public partial class DynamicEditorGrid : UserControl, IDynamicEditorHost
                 }
 
                 editor.Loaded = bLoaded;
-
-                editor.OnEditorValueChanged += EditorValueChanged;
             }
         }