You can save or cancel the DataObject in Xamarin.Forms SfDataForm by storing the dataobject.
You can refer the following article.
C#
Raise the property change event to store the DataObject.
private void DataForm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if(e.PropertyName == "DataObject")
formModel = dataForm.DataObject as DataFormModel;
}
C#
Cancel will reset the DataObject with stored dataobject.
private void OnCancel(object sender, EventArgs e)
{
dataForm.DataObject = formModel;
foreach (var property in dataForm.DataObject.GetType().GetProperties())
{
dataForm.UpdateEditor(property.Name);
}
}
C#
Saves the edited data by using Commit method.
private void OnSaved(object sender, EventArgs e)
{
dataForm.Validate();
dataForm.Commit();
formModel = dataForm.DataObject as DataFormModel;
}