public TodoItemViewModel(ITodoReduxDispatcher dispatcher, TodoItem state) { this.dispatcher = dispatcher; Update(state); StartItemEditCommand = new RelayCommand(StartItemEdit); EndItemEditCommand = new RelayCommand(EndItemEdit); CancelItemEditCommand = new RelayCommand(CancelItemEdit); }
public MainViewModel(ITodoReduxDispatcher dispatcher, Func <TodoItem, TodoItemViewModel> todoItemViewModelFactory) { this.dispatcher = dispatcher; this.todoItemViewModelFactory = todoItemViewModelFactory; dispatcher.StateChanged += UpdateReduxState; SetFilterCommand = new RelayCommand <ItemsFilter>(SetFilter, f => !state?.IsEditing ?? false); AddItemCommand = new RelayCommand(AddItem, () => !string.IsNullOrEmpty(state?.NewItemText)); RemoveCompletedCommand = new RelayCommand(RemoveCompleted, () => (state?.HasCompleted ?? false) && !(state?.IsEditing ?? false)); }