I have struggled with this in various forms for a while, see this: http://community.infragistics.com/forums/t/65217.aspx
Now I have a bit of a twist on my orignial question which relates to where the cursor is placed if the user cannot save (i.e. the data has errors). The exact logic I wish to achieve is this:
if the data was saved sucessfully, place the cursor on the first cell of the NewRow in the grid.
if the data was not saved, place the cursor on the first cell of the row they are editing (which may or may not be the NewRow).
Here is the logic I am using now, which does not work:
private void OnRuleUpdated(object sender, RecordUpdatedEventArgs e) { TBARule rule = (TBARule)e.Record.DataItem; bool ruleSaved = ViewModel.SaveRule(rule);
if (ruleSaved || e.Record == NewTBARuleRecord) { if (e.Record == NewTBARuleRecord) { Infragistics.Windows.DataPresenter.XamDataGrid dp = sender as Infragistics.Windows.DataPresenter.XamDataGrid; Dispatcher.BeginInvoke(new Action(() => { dp.ActiveRecord.RecordManager.CurrentAddRecord.Cells[0].IsActive = true; dp.ExecuteCommand(DataPresenterCommands.StartEditMode);
}), System.Windows.Threading.DispatcherPriority.Background, null); if(ruleSaved) NewTBARuleRecord = null; } else { Infragistics.Windows.DataPresenter.XamDataGrid dp = sender as Infragistics.Windows.DataPresenter.XamDataGrid; Dispatcher.BeginInvoke(new Action(() => { DataRecord record = dp.DataContext as DataRecord; record.Cells[0].IsActive = true; dp.ExecuteCommand(DataPresenterCommands.StartEditMode);
}), System.Windows.Threading.DispatcherPriority.Background, null); } } }
private void RulesGrid_RecordAdded(object sender, Infragistics.Windows.DataPresenter.Events.RecordAddedEventArgs e) { NewTBARuleRecord = e.Record; }
Thanks for the help,
Sam
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.