diff --git a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs index 5cf75287257..101a28e6d9b 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs @@ -139,7 +139,7 @@ public void CustomizeView(DefineData model, NodeView nodeView) VerticalAlignment = VerticalAlignment.Top, VerticalContentAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, - MinWidth = model.IsAutoMode ? 220 : 240, // initial value only, will change on enabled/disabled (crops the combobox arrow otherwise) + MinWidth = 200, Height = 30, FontSize = 12, Background = new SolidColorBrush(Color.FromRgb(42, 42, 42)), @@ -154,6 +154,12 @@ public void CustomizeView(DefineData model, NodeView nodeView) }; selectedItemDisplay.SetBinding(TextBox.TextProperty, selectedItemBinding); + var widthBinding = new Binding("IsEnabled") + { + Source = selectedItemDisplay, + Converter = new BooleanToWidthConverter() + }; + selectedItemDisplay.SetBinding(TextBox.WidthProperty, widthBinding); // Move the ComboBox to the placeholder var placeholderText = formControl.FindName("TextPlaceholder") as TextBox; @@ -172,8 +178,6 @@ public void CustomizeView(DefineData model, NodeView nodeView) Panel.SetZIndex(selectedItemDisplay, 2); Panel.SetZIndex(dropdown, 1); } - - selectedItemDisplay.IsEnabledChanged += selectedItemDisplay_IsEnabledChanged; } public new void Dispose() @@ -309,5 +313,19 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotImplementedException(); } } + + public class BooleanToWidthConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + bool isEnabled = (bool)value; + return isEnabled ? 200 : 220; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + } } } diff --git a/test/VisualizationTests/CustomNodeTests.cs b/test/VisualizationTests/CustomNodeTests.cs index e0a0d387d18..1c665dd0c13 100644 --- a/test/VisualizationTests/CustomNodeTests.cs +++ b/test/VisualizationTests/CustomNodeTests.cs @@ -266,7 +266,7 @@ public void TestDefineDataCorrectInheritanceDisplayedInAutoMode() Assert.IsTrue(errorListNode.IsAutoMode); Assert.IsFalse(errorListNode.IsList); - Assert.AreEqual(errorListNode.DisplayValue, "Select Types", "The node displays a type value, but it should not."); + Assert.AreEqual(errorListNode.DisplayValue, string.Empty, "The node displays a type value, but it should not."); } } }