This example showcases a few scenarios of adding validation to the listview Edit and Insert operations.
The general way to do that is to:
- Add the desired validation (forms, some async logic from a data service, whatever suits the project needs).
- Cancel the ListView event when validation fails (set the
IsCancelled
flag of the event arguments totrue
) to keep it in edit/insert mode.
In this sample project, you will find the following examples:
-
synchronous validation - one way to add an
EditForm
and instantiate anEditContext
to use for validation -
async methods - one way to use the edit form (or other remote validation) when the methods are
async
. -
custom edit form - an example of implementing all the editing/inserting logic with your own code without having to take into account any built-in ListView logic and capabilities - this provides you with full control over the rendering, logic, async operations and so on.
You may also find useful articles like the following ones on handling server-side validation: