HI,
You can do this by tracking the previous record in the viewmodel
Here is the binding for the XamDataGrid’s ActiveRecord property.
<igDP:XamDataGrid ExecutingCommand="xgrid1_ExecutingCommand" ActiveRecord="{Binding ActiveRecord, Mode=TwoWay}" RecordActivated="xgrid1_RecordActivated" Name="xgrid1" DataSource="{Binding People}">
Here is the property on the ViewModel:
Record activerecord;public Record ActiveRecord{ get { return activerecord; } set { if (changeactive) { activerecord = value; prevrecord = activerecord; NotifyPropertyChanged("ActiveRecord"); } else { activerecord = prevrecord; // throw new Exception("cant change record"); } } } Record prevrecord;public Record PrevRecord{ get { return prevrecord; } set { prevrecord = value; NotifyPropertyChanged("PrevRecord");}}
Record prevrecord;public Record PrevRecord{ get { return prevrecord; } set { prevrecord = value; NotifyPropertyChanged("PrevRecord");}}
When you run the sample, you can't change the XamDataGrid's ActiveRecord until you check the EnableActivation Checkbox.
Sincerely, MattDeveloper Support Engineer
You want to go neater (MVVM) friendly way you can you MVVMLights EventToCommand Trigger to bind to Command in your View Model
In that CheckActiveRecordChangeCommand (in your ViewModel). you can decide to Cancel moving to another record.
You will need to listen for RecordDeactivating event when using EventToCommand.