private void btnDelete_Click(object sender, RoutedEventArgs e) { Athlete athelete = ((FrameworkElement)sender).DataContext as Athlete; if (MessageBox.Show("Are you sure", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { if (athelete != null) { _athleteRepository.DeleteAthlete(athelete); _athleteRepository.Save(); _athleteManager.Athletes.Remove(athelete); _athleteManager.NextBib = _athleteRepository.GetMaxBib() + 1; } } }