Lesson 1: Set Data Object

  • 2 minutes to read

The DataFormView component allows you to quickly generate an edit form for your data object.

Create a New Application and Add a Data Form

  1. Create a new Xamarin.Forms cross-platform solution and add a DevExpress DataForm component.
  2. In the MainPage.xaml file of a .NET Standard project that has shared code, use the dxdf prefix to declare a namespace and add a DataFormView instance to the ContentPage:

                <dxdf:DataFormView x:Name="dataForm"/>

Set a Data Object

  1. Declare the PersonalInfo sample class that defines data to be edited via a data form.

    namespace DataFormExample {
        public class PersonalInfo {
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public DateTime BirthDate { get; set; }
            public virtual Gender Gender { get; set; }
            public string Password { get; set; }
            public string Email { get; set; }
            public string Phone { get; set; }
        public enum Gender { Female, Male, RatherNotSay }
  2. Assign the PersonalInfo object to the DataFormView.DataObject property.

    dataForm.DataObject = new PersonalInfo();

The data form detects all property types for the bound data object. It then displays the appropriate editor (based on each type) with the property name as the label.

The next lesson lists supported editor types and explains how to replace a data form’s default editors.