Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into definedata-bugfix…
Browse files Browse the repository at this point in the history
…-heterogenous-lists
  • Loading branch information
dnenov committed May 22, 2024
2 parents 0fb562b + e3ebfde commit 837245b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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;
Expand All @@ -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()
Expand Down Expand Up @@ -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();
}
}
}
}
2 changes: 1 addition & 1 deletion test/VisualizationTests/CustomNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}

0 comments on commit 837245b

Please sign in to comment.