private void PeopleListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedPerson = PeopleListBox.SelectedItem as Person; if (selectedPerson != null) { var window = new PersonFromListWindow(selectedPerson); if (window.ShowDialog() ?? false) { UpdatePeople(); } PeopleListBox.UnselectAll(); } }
//Add/Update/Delete person private void AddPersonButton_Click(object sender, RoutedEventArgs e) { if (selectedPerson != null) { var window = new PersonWindow(selectedPerson); if (window.ShowDialog() ?? false) { UpdatePeople(); } } else { var window = new PersonWindow(null); if (window.ShowDialog() ?? false) { UpdatePeople(); } } PeopleListBox.UnselectAll(); }