private void DeleteTestCase(object sender, RoutedEventArgs e) { TestCaseProxy testCaseToDelete = ((MenuItem)sender).DataContext as TestCaseProxy; TestManager manager = new TestManager(); manager.DeleteById(testCaseToDelete.Id); ProjectProxy projectProxy = this.UIProjectProxyList.Where(proj => proj.Areas.Any(a => a.ID == testCaseToDelete.AreaID)).FirstOrDefault(); if (projectProxy != null) { AreaProxy areaProxy = projectProxy.Areas.Where(a => a.ID == testCaseToDelete.AreaID).FirstOrDefault(); if (areaProxy != null) { areaProxy.TestCasesList.Remove(testCaseToDelete); this.SetCurrentTestCase(new TestCaseProxy()); } } }