private void Add_Click(object sender, RoutedEventArgs e) { if (_FAMLList.Count < MaxItems) { LearningDeliveryFAM tmp = _learnerDelivery.CreateLearningDeliveryFAM(); switch (FamType.ToString().ToUpper()) { case "ALB": case "LSF": case "ACT": tmp.LearnDelFAMType = FamType.ToString().ToUpper(); break; default: break; } switch (FamType.ToString().ToUpper()) { case "ALB": case "LSF": case "ACT": tmp.LearnDelFAMCode = "1"; break; default: break; } _FAMLList = GetLSFList(_learnerDelivery.LearningDeliveryFAMList); FamItemsCV = CollectionViewSource.GetDefaultView(_FAMLList as List <LearningDeliveryFAM>); tmp.IsSelected = true; FamItemsCV.MoveCurrentTo(tmp); FamItemsCV.Refresh(); OnPropertyChanged("FamItemsCV"); ShouldShowListView(); } else { MessageBox.Show(String.Format("You must remove and item fron the {1} list first.{0}{0} You have {2} items in the list at this time.", Environment.NewLine, UserControlTitle, _FAMLList.Count()) , "To many itams already." , MessageBoxButton.OK , MessageBoxImage.Information , MessageBoxResult.OK); } }
private void Remove_Click(object sender, RoutedEventArgs e) { if (FamItemsCV.CurrentItem != null) { LearningDeliveryFAM fam2Remove = FamItemsCV.CurrentItem as LearningDeliveryFAM; if (fam2Remove != null) { _learnerDelivery.Delete(fam2Remove); _FAMLList.Remove(fam2Remove); //int currentPost = FamItemsCV.CurrentPosition; if (!FamItemsCV.IsEmpty) { if (!FamItemsCV.MoveCurrentToPrevious()) { FamItemsCV.MoveCurrentToFirst(); FamItemsCV.Refresh(); OnPropertyChanged("FamItemsCV"); } if ((FamItemsCV.CurrentItem != null) && (FamItemsCV.CurrentItem != fam2Remove)) { LearningDeliveryFAM f = FamItemsCV.CurrentItem as LearningDeliveryFAM; f.IsSelected = true; } else { FamItemsCV.MoveCurrentToNext(); if (FamItemsCV.CurrentItem != null) { LearningDeliveryFAM f = FamItemsCV.CurrentItem as LearningDeliveryFAM; f.IsSelected = true; } } } FamItemsCV.Refresh(); } OnPropertyChanged("FamItemsCV"); ShouldShowListView(); } }