private void buttonRemoveProject_Click(object sender, RoutedEventArgs e) { // Item must be selected if (listBoxProjects.SelectedItem != null) { int index = listBoxProjects.SelectedIndex; // Display warning MessageBoxResult messageBoxResult = MessageBox.Show(string.Format("Do you want to remove project {0}", projects[index].ProjectName), "Warning", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { // Remove for list and update GUI projectMgr.DeleteAt(index); UpdateGUI(); } } }