public AbstractViewModel(Abstract obj) { this.Model = obj; this.AbstractWorks = new ObservableCollection <AbstractWorkViewModel>(); this.AbstractWorks.CollectionChanged += (sender, e) => { this.CurrentAbstractWork = AbstractWorks.FirstOrDefault(); }; foreach (var source in Model.AbstractWorks.ToList()) { AbstractWorks.Add(new AbstractWorkViewModel(source)); } AddAbstractWorkCommand = new DelegateCommand(o => AddAbstractWork()); RemoveAbstractWorkCommand = new DelegateCommand(o => RemoveAbstractWork(), o => CurrentAbstractWork != null); this.SelectFileCommand = new DelegateCommand(o => SelectFile()); this.OpenFolderCommand = new DelegateCommand(o => OpenFolder()); this.OpenFileCommand = new DelegateCommand(o => OpenFile()); SaveCommand = new DelegateCommand(o => Save()); SendEmailCommand = new DelegateCommand(o => SendEmailForAbstract(), o => CurrentAbstractWork != null); }
private void RemoveAbstractWork() { DataManager.Instance.RemoveAbstractWork(CurrentAbstractWork.Model); AbstractWorks.Remove(CurrentAbstractWork); OnPropertyChanged("AbstractWorks"); }