Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentlyEditing != null)
            {
                CurrentlyEditing.Text = TaskValueTextBox.Text;
                CurrentlyEditing      = null;
                AddTaskButton.Content = "Add Task";
            }
            else
            {
                var taskItem = new TaskListItem(TaskValueTextBox.Text);

                taskItem.OnEditClicked += (sender1, e1) =>
                {
                    StartEdit(sender1 as TaskListItem);
                };

                taskItem.OnDeleteClicked += (sender1, e1) =>
                {
                    Tasks.Remove(sender1 as TaskListItem);
                };

                Tasks.Add(taskItem);
                //this.ListItems.ItemsSource = Tasks;
            }

            TaskValueTextBox.Text = "";
        }
Пример #2
0
 private void StartEdit(TaskListItem item)
 {
     CurrentlyEditing      = item;
     AddTaskButton.Content = "Edit Task";
     TaskValueTextBox.Text = item.Text;
 }