//When the user selects a row in the datagrid private void dgv_Passport_SelectionChanged(object sender, SelectedCellsChangedEventArgs e) { if (passport.EMPPASSPORTSearchControl.ResultsGrid.SelectedItem != null) { EditingLastPassportInfo = (passport.EMPPASSPORTSearchControl.ResultsGrid.SelectedItem as HR_EMP_PASSPORT).Clone() as HR_EMP_PASSPORT; } }
//This is a event which fires whenever newitems arrive at the datagrid private void ItemSourceChanged(object sender, EventArgs e) { LastPassportInformation = passport.EMPPASSPORTSearchControl.ResultsGrid.ItemsSource as ObservableCollection <HR_EMP_PASSPORT>; passport.EMPPASSPORTGrid.DataContext = LastPassportInformation; if (LastPassportInformation.Count > 0) { EditingLastPassportInfo = LastPassportInformation[0].Clone(); } }