private void btnDeleteTask_Click(object sender, RoutedEventArgs e) { using (var context = new WorkdeskContext()) { var task = (WorkDeskManager.Desktop.Data.Task)TaskList.SelectedItem; if (null != task) { context.Tasks.Attach(task); context.Tasks.Remove(task); context.SaveChanges(); } } }
private void TaskList_SelectionChanged(object sender, SelectionChangedEventArgs e) { using (var context = new WorkdeskContext()) { WorkDeskManager.Desktop.Data.Task taskSelected = context.Tasks.Find(((WorkDeskManager.Desktop.Data.Task)TaskList.SelectedItem).Id); if (taskSelected != null) { txtWorksheetUrl.Text = taskSelected.WorksheetUrl; var activities = context.Activities.Where(t => t.Task.Id == taskSelected.Id).ToList(); if (activities != null) { ActivityList.ItemsSource = activities; ActivityList.DisplayMemberPath = "Description"; ActivityList.Items.Refresh(); } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { DispatcherTimer timer = new DispatcherTimer(); timer.Tick += timer_Tick; timer.Interval = new TimeSpan(0, 0, Properties.Settings.Default.IntervalSecs); timer.Start(); //TaskList.items using (var context = new WorkDeskManager.Desktop.Data.WorkdeskContext()) { var taskList = context.Tasks.ToList(); if (taskList != null) { TaskList.ItemsSource = taskList; TaskList.DisplayMemberPath = "Name"; } } }