// Contstructor for the main window, decides the data context and syncs // data from the database to the task listview public MainWindow() { InitializeComponent(); tasks = mD.taskDataTransfer(tasks); this.DataContext = tasks; }
// If we are only adding a task, all we need is the list to pass through public TaskDialog(TaskListViewModel tasks) { tasks.resetViewModel(); this.tasks = tasks; InitializeComponent(); SubmitButton.Content = "Add Task"; this.DataContext = tasks; }
// If we are editing a task, we need to pass through the task itself and the list public TaskDialog(TaskViewModel tsk, TaskListViewModel tasks) { InitializeComponent(); SubmitButton.Content = "Apply"; // This populates our ListView with the task data we are editing tasks.ID = tsk.ID; tasks.TaskName = tsk.Name; tasks.Priority = tsk.Priority; tasks.Complete = tsk.Complete; this.tasks = tasks; // This checks the appropriate radio button according to the priority of the // task we are editing switch (tasks.Priority) { case 1: noPr.IsChecked = true; break; case 2: somePr.IsChecked = true; break; case 3: veryPr.IsChecked = true; break; } // Changes the checkbox to match the task complete progress we are editing completeCB.IsChecked = tasks.Complete; this.DataContext = tasks; }