因此,当用户选择了不同的项目时,我尝试加载不同的字符串,我的代码:
void ModeSelectorSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var data1 = new string[]
{
"January 2012",
"February 2012",
"March 2012",
"April 2012",
};
var data2 = new string[]
{
"Married",
"Divorced",
"Buy new house",
"Get promotion",
};
if (_Menu2.SelectedIndex == 2)
{
_Menu3.ItemsSource = data1;
}
else
if (_Menu2.SelectedIndex == 3)
{
_Menu3.ItemsSource = data2;
}
}
当我只使用 1 个字符串时,它可以正常工作,但是一旦我尝试在同一个下拉菜单中加载 2 个不同的字符串,它就会关闭,这意味着它根本不显示任何字符串数据。我究竟做错了什么?