private void RemoveCourse(object parameter) { if (SelectedCourse != null && (MessageBox.Show("Are you sure you want to delete " + SelectedCourse.CourseName, "Training Database", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)) { IEnumerable <int> idlist = CourseList.Select(t => t.ID); db.Courses.Remove(SelectedCourse); //SaveDataChanges(null); CourseList = db.Courses.Local.Where(c => idlist.Contains(c.ID)).OrderBy(c => c.CourseName).ToList(); SelectedCourse = CourseList.FirstOrDefault(); NotifyPropertyChanged("Changed"); } }