Beispiel #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            ApprenticeshipFinancialRecord tmp = _learningDelivery.CreateApprenticeshipFinancialRecord();

            _apprenticeshipFinancialRecordList = _learningDelivery.ApprenticeshipFinancialRecordList;
            ApprenticeshipFinancialItemsCV     = CollectionViewSource.GetDefaultView(_learningDelivery.ApprenticeshipFinancialRecordList as List <ILR.ApprenticeshipFinancialRecord>);
            ApprenticeshipFinancialItemsCV.MoveCurrentTo(tmp);
            ApprenticeshipFinancialItemsCV.Refresh();
            OnPropertyChanged("ApprenticeshipFinancialItemsCV");
            ShouldShowListView();
        }
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            var removeButton = sender as Button;

            if (removeButton != null)
            {
                var parameter = removeButton.CommandParameter;

                if (parameter != null)
                {
                    ILR.ApprenticeshipFinancialRecord les2Remove = parameter as ILR.ApprenticeshipFinancialRecord;
                    les2Remove.IsSelected = true;

                    if (les2Remove != null)
                    {
                        ApprenticeshipFinancialItemsCV.MoveCurrentTo(les2Remove);
                        _learningDelivery.Delete(les2Remove);
                        _apprenticeshipFinancialRecordList.Remove(les2Remove);

                        if (!ApprenticeshipFinancialItemsCV.MoveCurrentToPrevious())
                        {
                            ApprenticeshipFinancialItemsCV.MoveCurrentToFirst();
                            ApprenticeshipFinancialItemsCV.Refresh();
                            OnPropertyChanged("ApprenticeshipFinancialItemsCV");
                        }

                        if (ApprenticeshipFinancialItemsCV.CurrentItem != null && ApprenticeshipFinancialItemsCV.CurrentItem != les2Remove)
                        {
                            ILR.ApprenticeshipFinancialRecord f = ApprenticeshipFinancialItemsCV.CurrentItem as ILR.ApprenticeshipFinancialRecord;
                            f.IsSelected = true;
                        }
                        else
                        {
                            ApprenticeshipFinancialItemsCV.MoveCurrentToNext();
                            if (ApprenticeshipFinancialItemsCV.CurrentItem != null)
                            {
                                ILR.ApprenticeshipFinancialRecord f = ApprenticeshipFinancialItemsCV.CurrentItem as ILR.ApprenticeshipFinancialRecord;
                                f.IsSelected = true;
                            }
                        }
                    }
                    ApprenticeshipFinancialItemsCV.Refresh();

                    OnPropertyChanged("ApprenticeshipFinancialItemsCV");
                    ShouldShowListView();
                }
            }
        }