CRUD Operations Support
The DataForm supports data operations such as adding, editing, and removing data items.
To provide better understanding on how these operations work, you need to be aware of the way the DataForm source collection is set—the
Source property accepts
IEnumerable values and manages them in a different manner depending on the data operation.
The DataForm provides the
Add operation, which becomes available only when either of the following conditions is met:
The collection is an
IListwithout a fixed size and with a public default constructor.
The collection implements an
Addmethod and has a public default constructor. The
Addmethod requires a single parameter, which is the object you want to add to your collection.
Similar to the
Add operation, you can remove items only if wither of the following conditions are met:
The collection is an
IListwithout a fixed size.
The collection implements a
Removemethod with a single parameter, which is the object that will be removed from the collection.
If the current item is not null and the DataForm is not in edit mode, the Edit button will be enabled and the editing functionality will be available.
If the items of the data source implement the
IEditableObject or the
INotifyPropertyChanged interface, you will be able to revert any pending changes with the Cancel button. In this case, you have to set the
EnablePropertyChangedBasedCancel property of the DataForm to
EnablePropertyChangedBasedCancelis not supported when the DataForm utilizes custom data templates.
The DataForm provides options for editing types that do not implement the
INotifyPropertyChanged interfaces. In such cases, however, the cancel edit feature will not be available and the Cancel button will not be enabled.
- For more information on the behavior of the Save and Cancel buttons, refer to the article on AutoCommit Settings.
- For detailed explanations on implementing the
IEditableObject, refer to this MSDN article.
The DataForm exposes the
AutoEdit property, which indicates whether the component will automatically enter its edit mode when users load or navigate between items. By default,
AutoEdit is disabled and is set to
False. To enable the edit mode of the DataForm by default and avoid the need for users to explicitly click the Edit button every time they want to edit a record, set
Trueremoves the Add button and the user won't be able to add new entries.