我有一个关于listbox的问题。在我的程序中,当我点击一个ListBoxItem时,我想要在打开窗口之前先预订它。但问题是它首先触发事件,然后再改变选择。代码:
private void LB_Playlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LB_Playlist.SelectedItem != null)
{
try
{
List<string> _tempList = new List<string>();
File_Load_List(LB_Playlist.SelectedItem.ToString(), _tempList);
LoadListIntoBox(_tempList);
G_SongList.Visibility = Visibility.Visible;
AnimationMove(G_Playlist, G_Playlist.Margin, new Thickness(-264, 0, 0, 0), AnimationDuration, true);
AnimationMove(G_SongList, new Thickness(264, 0, 0, 0), new Thickness(0, 0, 0, 0), AnimationDuration, false);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
当我尝试使用MessageBox.Show(LB_Playlist.SelectedIndex.ToString())时,它能够正常工作,选项也被改变了,但是消息没有显示。有没有办法改变这种情况?