Add Method
We want to be able to add items to and remove items from the collection.
In the next step, we'll add a TextBox
and a Button
to let the user add new To-Do items.
<dot:TextBox Text="{value: NewItem}" />
<dot:Button Click="{command: Add()}"
Text="Add Item" />
However, we need to do something else first.
Tasks
Let's write the adding logic first.
- Add a
string
property calledNewItem
to the ViewModel. - Inside the
Add
method, create a newToDoItem
object and initialize itsText
property toNewItem
. Then add the instance toItems
.
Message | Line | Column | |
---|---|---|---|