ItemViewModel represents the to-do list item in a view that can be used to create new items and to edit existing items:
- In the ViewModels folder, create a class called ItemViewModel.
- Add the following code:
using DoToo.Models;
using DoToo.Repositories;
using System;
using System.Windows.Input;
using Xamarin.Forms;
namespace DoToo.ViewModels
{
public class ItemViewModel : ViewModel
{
private readonly TodoItemRepository repository;
public ItemViewModel(TodoItemRepository repository)
{
this.repository = repository;
}
}
}
The pattern is the same as for the previous two ViewModel classes:
- We use dependency injection to pass the TodoItemRepository class to the ViewModel object.
- We use inheritance from the ViewModel base class to add the common features defined by the base class