在我的测试场景中,所有组合框都显示相同的值(“<--Select-->”)。
private bool AtLeastOnePlatypusSelected()
{
string DefaultPlatypusValue = "<--Select-->";
return (cmbxWeek1.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek2.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek3.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek4.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek5.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek6.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek7.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek8.SelectedValue != DefaultPlatypusValue) ||
(cmbxWeek9.SelectedValue != DefaultPlatypusValue);
}
...但是这个函数正在返回 true。
这是另一个组合框代码:
public ObservableCollection<ComboBoxItem> cbItems { get; set; }
public ComboBoxItem SelectedcbItem { get; set; }
private Dictionary<int, int> PointNumToWeekNumPairings = new Dictionary<int, int>();
public MainWindow()
{
InitializeComponent();
DataContext = this;
cbItems = new ObservableCollection<ComboBoxItem>();
var cbItem = new ComboBoxItem { Content = "<--Select-->" };
SelectedcbItem = cbItem;
cbItems.Add(cbItem);
cbItems.Add(new ComboBoxItem { Content = "Tony Iommi" });
cbItems.Add(new ComboBoxItem { Content = "Mike McCarthy" });
cbItems.Add(new ComboBoxItem { Content = "Micah Profit" });
cbItems.Add(new ComboBoxItem { Content = "Allan Poe" });
cbItems.Add(new ComboBoxItem { Content = "Bill Bailey" });
cbItems.Add(new ComboBoxItem { Content = "Duane Eddy" });
cbItems.Add(new ComboBoxItem { Content = "John Kennedy" });
cbItems.Add(new ComboBoxItem { Content = "Bert Erneson" });
cbItems.Add(new ComboBoxItem { Content = "Clyde Valouch" });
cbItems.Add(new ComboBoxItem { Content = "Micky Thompson" });
}
Pork Link Wray 查尔斯狄更斯在这里发生了什么?!?