public ProductExplorerViewModel(IEventAggregator eventAggregator, ISaveFileService saveFileService)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) return;

            this._eventAggregator = eventAggregator;
            this._saveFileService = saveFileService;

            this._applicationUnit = new ApplicationUnit();
            this.Products = new ObservableCollection<Product>(this._applicationUnit.Products.GetAll().ToList());
            this.Products.CollectionChanged += (s,e) => RaiseCanExecuteCommands();

            this.DeleteProductCommand = new RelayCommand(DeleteProductCommandExecute, DeleteProductCommandCanExecute);
            this.SaveChangesCommand = new RelayCommand(SaveChangesCommandExecute);
            this.RefreshCommand = new RelayCommand(RefreshCommandExecute);
            this.SaveAsCSVCommand = new RelayCommand(SaveAsCSVCommandExecute, SaveAsCSVCommandCanExecute);

            this.RegisterCommand(this.DeleteProductCommand);
            this.RegisterCommand(this.SaveAsCSVCommand);
        }
Exemple #2
0
 protected void RegisterCommand(RelayCommand relayCommand)
 {
     this._relayCommands.Add(relayCommand);
 }