private void SetupListData() { LearnerItemsCV = null; if (App.ILRMessage.LearnerList.Count > 0) { LearnerItemsCV = CollectionViewSource.GetDefaultView(App.ILRMessage.LearnerList); using (LearnerItemsCV.DeferRefresh()) { LearnerItemsCV.SortDescriptions.Clear(); LearnerItemsCV.SortDescriptions.Add(new SortDescription("IsComplete", ListSortDirection.Ascending)); LearnerItemsCV.SortDescriptions.Add(new SortDescription("LearnRefNumber", ListSortDirection.Ascending)); LearnerItemsCV.Filter = LearnerFilter; } } else { if (LearnerItemsCV != null) { LearnerItemsCV.Refresh(); } //OnPropertyChanged("LearnerItemsCV"); LearnerDetailGrid.Visibility = System.Windows.Visibility.Hidden; LearnerItemsCV = null; } }
private void SetupListData() { LearnerItemsCV = null; if (App.ILRMessage.LearnerList.Count > 0) { LearnerItemsCV = CollectionViewSource.GetDefaultView(App.ILRMessage.LearnerList); LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); LearnerItemsCV.Filter = LearnerFilter; LearnerDetailGrid.Visibility = System.Windows.Visibility.Visible; LearnerItemsCV.MoveCurrentTo(LearnerItemsCV.CurrentItem as Learner); SetSubControl(LearnerItemsCV.CurrentItem as Learner); LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); } else { if (LearnerItemsCV != null) { LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); } OnPropertyChanged("LearnerItemsCV"); LearnerDetailGrid.Visibility = System.Windows.Visibility.Hidden; LearnerItemsCV = null; } }
private void RemoveLearner_Click(object sender, RoutedEventArgs e) { if (LearnerItemsCV.CurrentItem != null) { Learner lr2Remove = LearnerItemsCV.CurrentItem as Learner; if (lr2Remove != null) { MessageBoxResult result = MessageBox.Show(String.Format("Are you sure you want to delete Learner {0} {0} Learner Ref - {3} {0} Name : {1} {2}", Environment.NewLine, lr2Remove.GivenNames, lr2Remove.FamilyName, lr2Remove.LearnRefNumber) , "Confirmation" , MessageBoxButton.YesNo , MessageBoxImage.Stop , MessageBoxResult.No); if (result == MessageBoxResult.Yes) { //int currentPost = LearnerItemsCV.CurrentPosition; App.ILRMessage.Delete(lr2Remove); App.ILRMessage.Save(); LearnerItemsCV.Refresh(); if (App.ILRMessage.LearnerList.Count > 0) { if (!LearnerItemsCV.MoveCurrentToPrevious()) { LearnerItemsCV.MoveCurrentToFirst(); LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); } if ((LearnerItemsCV.CurrentItem != null) && (LearnerItemsCV.CurrentItem != lr2Remove)) { Learner lr = LearnerItemsCV.CurrentItem as Learner; lr.IsSelected = true; } else { LearnerItemsCV.MoveCurrentToNext(); if (LearnerItemsCV.CurrentItem != null) { Learner lr = LearnerItemsCV.CurrentItem as Learner; lr.IsSelected = true; } } LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); } else { SetupListData(); } } } } }
private void AddLearner_Click(object sender, RoutedEventArgs e) { Learner NewLr = App.ILRMessage.CreateLearner(); App.ILRMessage.Save(); if (App.ILRMessage.LearnerList.Count == 1) { SetupListData(); } NewLr.IsSelected = true; LearnerItemsCV.MoveCurrentTo(NewLr); LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); }
private void AddLearner_Click(object sender, RoutedEventArgs e) { //if (LearnerItemsCV != null && LearnerItemsCV.CurrentItem != null) //{ // foreach (Learner learner in LearnerItemsCV) // { // if (!string.IsNullOrWhiteSpace(learner.IncompleteMessage)) // { // MessageBox.Show($"Please complete all mandatory fields for learner {learner.LearnRefNumber} before proceeding" // , "Cannot proceed" // , MessageBoxButton.OK // , MessageBoxImage.Error // , MessageBoxResult.OK); // return; // } // } //} Learner newLr = App.ILRMessage.CreateLearner(); App.ILRMessage.Save(); if (App.ILRMessage.LearnerList.Count == 1) { SetupListData(); } foreach (Learner l in LearnerItemsCV) { //if (l != newLr) l.IsSelected = false; } newLr.IsSelected = true; DataItemListBox.SelectedItem = newLr; //LearnerItemsCV.MoveCurrentTo(newLr); LearnerItemsCV.Refresh(); OnPropertyChanged("LearnerItemsCV"); newLr.RefreshData(); }