Beispiel #1
0
        private void AddTodo_Click(object sender, RoutedEventArgs e)
        {
            //set default values to be added to todo collection
            int    userIDToPass = 1;
            var    lastTodo     = Todos.Last();
            int    lastTodoId   = lastTodo.id += 1;
            bool   newCompleted = false;
            string titleCreated = AddNewTodoField.Text;

            var newTodo = new Todo()
            {
                userId    = userIDToPass,
                id        = lastTodoId,
                title     = titleCreated,
                completed = newCompleted
            };

            //add to list of todos at the beginning of the list
            Todos.Insert(0, newTodo);

            //show new todo in details view
            SelectedTodo.Clear();
            SelectedTodo.Add(newTodo);

            //clear searhc field
            AddNewTodoField.Text = "";
        }