// get all tasks when form loading private void PopulateTasks(Boolean onlyCurrentTasks) { //load all tasks to the datagrid TaskManagement taskMgt = new TaskManagement(); try { datagridTask.Columns.Clear(); //get all tasks by current date datagridTask.ItemsSource = taskMgt.GetTasks(onlyCurrentTasks).GetAllRecords(); } catch (Exception ex) { MessageBox.Show("Get all tasks errors occured", ex.Message); } }