Data annotations in Xamarin DataForm (SfDataForm)

The data form supports the following attribute, and these attributes can be accessible using System.ComponentModel.DataAnnotation assembly.

Display attribute

Property Details

Name

Specifies the label text.

GroupName

Specifies the group name which groups the fields in the data form. Refer to

here

for more details.

ShortName

Specifies the label text. It takes higher priority than Name.

AutoGenerateField

Specifies whether the field should be auto generated or not. Refer to

here

for more details.

Prompt

Specifies watermark text for the editor. Refer to

here

for more details.

Order

Specifies the order of field in the data form. Refer to

here

for more details.

Validation attributes

Property Details
MinLength Specifies the required minimum length. Refer to

here

for more details.
MaxLength Specifies the required maximum length. Refer to

here

for more details.
Required Specifies the required data field value. Refer to

here

for more details.
Range Specifies the maximum and minimum values. Refer to

here

for more details.

Bindable attribute

It specifies whether the field should be auto generated or not. Refer to here for more details.

Editable attribute

It specifies whether the data field is editable or not.

ReadOnly attribute

It specifies whether the data field is read only or not. Refer to here for more details.

EnumDataType attribute

It specifies enum type for the data field.

DataType attribute

It specifies data type for the field.

Supported data types are Text, MultilineText, Date, DateTime, Time, and Currency.

Refer to here for more details.

DisplayFormat attribute

It specifies how data fields are displayed and formatted.

Supported data types are currency, percentage, date, time.

Property Details
DataFormatString Specifies the display format of the field value.
Editor FormatString
Currency {0:C}
Percentage {0:P}
Date {0:D}
Time {0:T}
dataForm.DataObject = new ContactInfo();

public class ContactInfo
{
    private int markPercentage;

    [DisplayFormat(DataFormatString ="{0:P}")]
    public String MarkPercentage
    {
        get
        {
            return markPercentage;
        }
        set
        {
            markPercentage = value;
        }
    }
}

CustomDataType attribute

The Percent data type is supported. Refer to here for more details.

Custom attribute

The data form supports the following custom attribute, and these attributes can be accessible using Syncfusion.SfDataForm.XForms.

DisplayOptions attribute

Property Details

RowSpan

Specifies the row span for the data form item. Refer to

here

for more details.

ColumnSpan

Specifies the column span for the data form item. Refer to

here

for more details.

ValidMessage

Specifies positive message to be shown when validation is passed. Refer to

here

for more details.

ImageSource

Specifies the image source for loading image instead of label. Refer to

here

for more details.

ShowLabel

Specifies whether the label should be visible or not. Refer to

here

for more details.

Converter attribute

Property Details

ConverterType

Specifies the Converter type which converts the original value in different format or as different value. Refer to here for more details.

DateRange attribute

Property Details

MinYear

Specifies the required minimum year.

MinMonth

Specifies the required minimum month.

MinDay

Specifies the required minimum day.

MaxYear

Specifies the required maximum year.

MaxMonth

Specifies the required maximum month.

MaxDay

Specifies the required maximum day.

Refer to here for more details.