【发布时间】:2020-07-24 08:27:05
【问题描述】:
我有一个枚举形式:
public enum BlueOrRed { None, Blue, Red}
目前我将其绑定到代码中的组合框,因为绑定依赖于另一个组合框中的选择:
if (OtherComboBox.SelectedItem == Color.BlueOrRed)
{
ThisComboBOx.ItemsSource = Enum.GetValues(typeof(BlueOrRed));
}
else ...
我需要选项,BlueOrRed 在后面的代码中也可以是 None。但我不想在 ComboBox 中显示该选项。
我知道有一个类似的Question,但不幸的是,这个答案并不真正适用于我的问题。
【问题讨论】:
-
ItemsSource = new BlueOrRed[] { BlueOrRed.Blue, BlueOrRed.Red }; -
可能是answer。但我没有测试过。
标签: c# wpf data-binding enums