我尝试了很多周才意识到Selection Changed
,但我无法做到这一点,因为SelectedIndex
总是-1
。请帮帮我。
源代码:
private void MondayListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (MondayListBox.SelectedIndex == -1)
MessageBox.Show("nain!!"+ MondayListBox.SelectedIndex.ToString()+"");
//return;
// Navigate to the new page
NavigationService.Navigate(new Uri("/data.xaml?selectedItem=" + MondayListBox.SelectedIndex, UriKind.Relative));
// Reset selected index to -1 (no selection)
MondayListBox.SelectedIndex = -1;
}