//When the user selects a row in the datagrid private void dgv_EmpNonCashbenefit_SelectionChanged(object sender, SelectedCellsChangedEventArgs e) { if (benefit.EmpNonCashBenefitSearchControl.ResultsGrid.SelectedItem != null) { EditingLastBenefitInfo = (benefit.EmpNonCashBenefitSearchControl.ResultsGrid.SelectedItem as HR_EMP_NONCASH_BENEFIT).Clone() as HR_EMP_NONCASH_BENEFIT; } }
//This is a event which fires whenever newitems arrive at the datagrid private void ItemSourceChanged(object sender, EventArgs e) { LastBenefitInformation = benefit.EmpNonCashBenefitSearchControl.ResultsGrid.ItemsSource as ObservableCollection <HR_EMP_NONCASH_BENEFIT>; benefit.EmpNonCashBenefitGrid.DataContext = LastBenefitInformation; if (LastBenefitInformation.Count > 0) { EditingLastBenefitInfo = LastBenefitInformation[0].Clone(); } }