private void ButtonDeleteParticipant_Click(object sender, RoutedEventArgs e) { Person participantToDelete = (Person)MyListOfParticipants.SelectedItem; if (!participantToDelete.Equals(MyListOfPersons.SelectedItem) && participantToDelete != null) { Agenda agendaToDeleteFrom = (Agenda)MyListOfAgendas.SelectedItem; int indexToDeleteParticipant = agendaToDeleteFrom.GetIndexOfParticipant(participantToDelete); int indexToDeleteAgenda = participantToDelete.GetIndexOfAgenda(agendaToDeleteFrom); agendaToDeleteFrom.DeleteParticipant(indexToDeleteParticipant); participantToDelete.DeleteAgenda(indexToDeleteAgenda); MyListOfParticipants.Items.RemoveAt(MyListOfParticipants.Items.IndexOf(participantToDelete)); } }
private void ButtonDeleteAgenda_Click(object sender, RoutedEventArgs e) { Agenda thisPersonsAgenda = (Agenda)MyListOfAgendas.SelectedItem; if (thisPersonsAgenda != null) { Person thisPerson = (Person)MyListOfPersons.SelectedItem; int indexToDeleteParticipant = thisPersonsAgenda.GetIndexOfParticipant(thisPerson); int indexToDeleteAgenda = thisPerson.GetIndexOfAgenda(thisPersonsAgenda); thisPersonsAgenda.DeleteParticipant(indexToDeleteParticipant); thisPerson.DeleteAgenda(indexToDeleteAgenda); MyListOfAgendas.Items.RemoveAt(MyListOfAgendas.Items.IndexOf(thisPersonsAgenda)); MyListOfParticipants.Items.Clear(); MyListOfActivities.Items.Clear(); } }