public void AddNewTodo(NewTodoItemViewModel model, KeyEventArgs e) { if (e.Key == Key.Return && !string.IsNullOrWhiteSpace(model.Text)) { var item = new TodoItem { Text = model.Text, DueDate = model.DueDate, Tags = new BindableCollection<Tag>() }; this.TodoItems.Add(new TodoItemViewModel(item)); this.repository.Add(item); this.repository.Save(); model.Clear(); } }
public TodoItemViewModel(TodoItem item) { this.item = item; this.tags = new BindableCollection<TagViewModel>(); foreach (var tag in item.Tags) { var model = new TagViewModel(tag); this.tags.Add(model); model.OnRemove += this.OnRemoveTag; } }