public ActionsViewModel(IPackageManager packageManager, List<PackageAction> actions) { DisplayName = ""; List = new ObservableCollection<PackageAction>(actions); List.CollectionChanged += (sender, args) => RaisePropertyChanged(() => OrderedList); var eventHandler = new PropertyChangedEventHandler((sender, args) => { if (List.Any(n => n.Progress != 100)) return; CanClose = true; RaisePropertyChanged(() => CanClose); // TODO: if autoclose in options: TryClose(true) }); actions.ForEach(n => n.SubscribeToPropertyChanged(eventHandler)); foreach (var action in actions) { action.ActionAdded += a => DispatcherHelper.CheckBeginInvokeOnUI(() => List.Add(a)); } CloseCommand = new RelayCommand(() => TryClose(true)); packageManager.Execute(actions.ToArray()); }