private void CreateTask_Click(object sender, RoutedEventArgs e) { string taskName = TaskNameBox.Text; int prior = TaskPriorBar.Value - 1; if (taskName.Length == 0) { MessageBox.Show("请输入任务名称!"); return; } if (TaskDueDateBox.SelectedDate == null) { MessageBox.Show("请选择截止日期!"); return; } DateTime duedate = TaskDueDateBox.SelectedDate.Value; MyTask.AddTask(new MyTask { Title = taskName, Priority = prior, Due = duedate }); NewTaskExpander.IsExpanded = false; TaskNameBox.Text = ""; TaskPriorBar.Value = 3; TaskDueDateBox.SelectedDate = null; drawTaskCards(); }