menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfDataForm - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfDataForm

    Initializes a new instance of the SfDataForm class.

    Inheritance
    System.Object
    SfView
    SfDataForm
    Implements
    IDrawableLayout
    Microsoft.Maui.Graphics.IDrawable
    Microsoft.Maui.IAbsoluteLayout
    Microsoft.Maui.ILayout
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IContainer
    System.Collections.Generic.IList<Microsoft.Maui.IView>
    System.Collections.Generic.ICollection<Microsoft.Maui.IView>
    System.Collections.Generic.IEnumerable<Microsoft.Maui.IView>
    System.Collections.IEnumerable
    Microsoft.Maui.ISafeAreaView
    Microsoft.Maui.IPadding
    Microsoft.Maui.ICrossPlatformLayout
    Microsoft.Maui.IVisualTreeElement
    Inherited Members
    SfView.ArrangeContent(Rect)
    SfView.ArrangeOverride(Rect)
    SfView.Children
    SfView.ClipToBounds
    SfView.GetSemanticsNodesCore(Double, Double)
    SfView.IDrawableLayout.DrawingOrder
    SfView.IDrawableLayout.InvalidateDrawable()
    SfView.MeasureOverride(Double, Double)
    SfView.OnDraw(ICanvas, RectF)
    SfView.OnHandlerChanged()
    SfView.Padding
    Namespace: Syncfusion.Maui.DataForm
    Assembly: Syncfusion.Maui.DataForm.dll
    Syntax
    public class SfDataForm : SfView, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, ICrossPlatformLayout, IVisualTreeElement, ISemanticsProvider, IDataFormItemInfo, IDataFormInfo, IParentThemeElement, IThemeElement
    Remarks

    The DataForm control is used to manage data and develop various forms such as login, reservation, data entry and so on.

    Examples

    The following code demonstrates, how to bind DataObject and populate editors in the dataform control.

    # [XAML](#tab/tabid-1)
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding ContactsInfo}"
                         AutoGenerateItems="True">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    # [C#](#tab/tabid-2)
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    # [C#](#tab/tabid-3)
    public class ContactsInfo
    {
       public string FirstName { get; set; }
       public string MiddleName { get; set; }
       public string LastName { get; set; }
       public string ContactNumber { get; set; }
       public string Email { get; set; }
       public string Address { get; set; }
       public DateTime? BirthDate { get; set; }
       public string GroupName { get; set; }
    }
    # [C#](#tab/tabid-4)
    this.dataForm.DataObject = new DataFormViewModel().ContactsInfo;

    Constructors

    SfDataForm()

    Initializes a new instance of the SfDataForm class.

    Declaration
    public SfDataForm()

    Fields

    AutoGenerateItemsProperty

    Identifies the AutoGenerateItems dependency property.

    Declaration
    public static readonly BindableProperty AutoGenerateItemsProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for AutoGenerateItems dependency property.

    ColumnCountProperty

    Identifies the ColumnCount dependency property.

    Declaration
    public static readonly BindableProperty ColumnCountProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ColumnCount dependency property.

    CommitModeProperty

    Identifies the CommitMode dependency property.

    Declaration
    public static readonly BindableProperty CommitModeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for CommitMode dependency property.

    DataObjectProperty

    Identifies the DataObject dependency property.

    Declaration
    public static readonly BindableProperty DataObjectProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for DataObject dependency property.

    DefaultLayoutSettingsProperty

    Identifies the DefaultLayoutSettings dependency property.

    Declaration
    public static readonly BindableProperty DefaultLayoutSettingsProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for DefaultLayoutSettings dependency property.

    EditorTextStyleProperty

    Identifies the EditorTextStyle dependency property.

    Declaration
    public static readonly BindableProperty EditorTextStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for EditorTextStyle dependency property.

    ErrorLabelTextStyleProperty

    Identifies the ErrorLabelTextStyle dependency property.

    Declaration
    public static readonly BindableProperty ErrorLabelTextStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ErrorLabelTextStyle dependency property.

    GroupHeaderTemplateProperty

    Identifies the GroupHeaderTemplate dependency property.

    Declaration
    public static readonly BindableProperty GroupHeaderTemplateProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for GroupHeaderTemplate dependency property.

    IsReadOnlyProperty

    Identifies the IsReadOnly dependency property.

    Declaration
    public static readonly BindableProperty IsReadOnlyProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for IsReadOnly dependency property.

    ItemManagerProperty

    Identifies the ItemManager dependency property.

    Declaration
    public static readonly BindableProperty ItemManagerProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ItemManager dependency property.

    ItemsProperty

    Identifies the Items dependency property.

    Declaration
    public static readonly BindableProperty ItemsProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Items dependency property.

    ItemsSourceProviderProperty

    Identifies the ItemsSourceProvider dependency property.

    Declaration
    public static readonly BindableProperty ItemsSourceProviderProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ItemsSourceProvider dependency property.

    LabelTextStyleProperty

    Identifies the LabelTextStyle dependency property.

    Declaration
    public static readonly BindableProperty LabelTextStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LabelTextStyle dependency property.

    LayoutTypeProperty

    Identifies the LayoutType dependency property.

    Declaration
    public static readonly BindableProperty LayoutTypeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LayoutType dependency property.

    TextInputLayoutSettingsProperty

    Identifies the TextInputLayoutSettings dependency property.

    Declaration
    public static readonly BindableProperty TextInputLayoutSettingsProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for TextInputLayoutSettings dependency property.

    ValidationModeProperty

    Identifies the ValidationMode dependency property.

    Declaration
    public static readonly BindableProperty ValidationModeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ValidationMode dependency property.

    ValidMessageLabelTextStyleProperty

    Identifies the ValidMessageLabelTextStyle dependency property.

    Declaration
    public static readonly BindableProperty ValidMessageLabelTextStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ValidMessageLabelTextStyle dependency property.

    Properties

    AutoGenerateItems

    Gets or sets a value indicating whether auto generate the DataFormItems in the data form.

    Declaration
    public bool AutoGenerateItems { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is true.

    Remarks

    The custom dataform Items can be generated by setting AutoGenerateItems to false/>.

    Examples

    The below examples shows, how to set the AutoGenerateItems to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         AutoGenerateItems="False">
    </dataForm:SfDataForm>
    this.dataForm.AutoGenerateItems = false;
    See Also
    Items
    DataObject

    ColumnCount

    Gets or sets the value representing the number of editors to be arranged per row in the data form.

    Declaration
    public int ColumnCount { get; set; }
    Property Value
    Type Description
    System.Int32

    The default value is 1.

    Examples

    The below examples shows, how to set the ColumnCount to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         AutoGenerateItems="False"
                         ColumnCount="2">
     <dataForm:SfDataForm.Items>
        <dataForm:DataFormTextItem FieldName="First Name"/>
        <dataForm:DataFormTextItem FieldName="Last Name"/>
        <dataForm:DataFormTextItem FieldName="Contact Number"/>
        <dataForm:DataFormDateItem FieldName="Date of Birth"/>
        <dataForm:DataFormTextItem FieldName="Email"/>
        <dataForm:DataFormMultilineItem FieldName="Address"/>
      </dataForm:SfDataForm.Items>
    </dataForm:SfDataForm>
    this.dataForm.AutoGenerateItems = false;
    this.dataForm.ColumnCount = 2;
    var items = new ObservableCollection<DataFormViewItem>();
    items.Add(new DataFormTextItem() { FieldName = "First Name" });
    items.Add(new DataFormTextItem() { FieldName = "Last Name" });
    items.Add(new DataFormTextItem() { FieldName = "Contact Number" });
    items.Add(new DataFormDateItem() { FieldName = "Date of Birth" });
    items.Add(new DataFormTextItem() { FieldName = "Email" });
    items.Add(new DataFormMultilineItem() { FieldName = "Address" });
    this.dataForm.Items = items;
    See Also
    ItemsOrderInRow
    Items
    DataObject
    DefaultLayoutSettings

    CommitMode

    Gets or sets the value that determines when to commit values that users enter in the data form’s editors to the bound data object.

    Declaration
    public DataFormCommitMode CommitMode { get; set; }
    Property Value
    Type Description
    DataFormCommitMode

    The default value is LostFocus.

    Remarks

    The CommitMode property specifies when input values should be committed to the underlying data object. The following modes are available:

    • The PropertyChanged - a value is committed after changes.
    • The LostFocus - a value is committed when the editor loses focus (a user taps outside the editor or presses Enter on a device’s keyboard).
    • The Manual - a value is committed when the Commit() method is called.
    Examples

    The below examples shows, how to set the CommitMode to the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         CommitMode="PropertyChanged"
                         DataObject="{Binding ContactsInfo}">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    public class ContactsInfo
    {
       public string FirstName { get; set; }
       public string LastName { get; set; }
       public string ContactNumber { get; set; }
       public string Email { get; set; }
       public string Address { get; set; }
    }
    this.dataForm.CommitMode = DataFormCommitMode.PropertyChanged;
    this.dataForm.DataObject = new DataFormViewModel().ContactsInfo;

    DataObject

    Gets or sets the value which is used to set the editors to the data form.

    Declaration
    public object DataObject { get; set; }
    Property Value
    Type
    System.Object
    Remarks

    The data object DataObject value to view or edit the data form properties, and the data form generates the editors and labels from the public properties of the data object. This property is applicable to only when the AutoGenerateItems property is set to true.

    Examples

    The below examples shows, how to set the editors to the DataObject in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding ContactsInfo}">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    public class ContactsInfo
    {
       public string FirstName { get; set; }
       public string LastName { get; set; }
       public string ContactNumber { get; set; }
       public string Email { get; set; }
       public string Address { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().ContactsInfo;
    See Also
    Items
    AutoGenerateItems
    GenerateDataFormItem
    ItemsSourceProvider

    DefaultLayoutSettings

    Gets or sets the settings to customize default layout (Holds label and editor) settings.

    Declaration
    public DataFormDefaultLayoutSettings DefaultLayoutSettings { get; set; }
    Property Value
    Type Description
    DataFormDefaultLayoutSettings

    The default value of LabelPosition is Left, LabelWidth is "(DataFormItemLength(0.4, DataFormItemLengthUnitType.Star))", and EditorWidth is "(DataFormItemLength(0.4, DataFormItemLengthUnitType.Star))".

    Remarks

    The DefaultLayoutSettings property takes precedence when explicitly defined.

    Examples

    The below examples shows, how to set the DefaultLayoutSettings to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
      <dataForm:SfDataForm.DefaultLayoutSettings>
        <dataForm:DataFormDefaultLayoutSettings
           LabelPosition = "Top"/>
      </dataForm:SfDataForm.DefaultLayoutSettings>
    </dataForm:SfDataForm>
    this.dataForm.DefaultLayoutSettings = new DataFormDefaultLayoutSettings()
    {
       LabelPosition = DataFormLabelPosition.Top,
       LabelWidth = new DataFormItemLength(0.3, DataFormItemLengthUnitType.Star),
       EditorWidth = new DataFormItemLength(0.10, DataFormItemLengthUnitType.Star)
    };
    See Also
    DataObject
    Items
    EditorTextStyle
    LabelTextStyle
    ErrorLabelTextStyle

    EditorTextStyle

    Gets or sets the style of editor text, that used to customize the text color, font, font size, font family and font attributes.

    Declaration
    public DataFormTextStyle EditorTextStyle { get; set; }
    Property Value
    Type Description
    DataFormTextStyle

    The default value of TextColor is Microsoft.Maui.Graphics.Colors.Black, FontSize is 16, FontFamily is null, FontAttributes is Microsoft.Maui.Controls.FontAttributes.None.

    Remarks

    The EditorTextStyle property takes precedence when explicitly defined.

    Examples

    The below examples shows, how to set the EditorTextStyle to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
     var editorTextStyle = new DataFormTextStyle()
     {
       TextColor = Colors.Orange,
       FontSize = 12,
     };
     this.dataForm.EditorTextStyle = editorTextStyle;
    See Also
    DataObject
    Items
    LabelTextStyle
    ErrorLabelTextStyle
    ValidMessageLabelTextStyle

    ErrorLabelTextStyle

    Gets or sets the style of error label text, that used to customize the text color, font, font size, font family and font attributes.

    Declaration
    public DataFormTextStyle ErrorLabelTextStyle { get; set; }
    Property Value
    Type Description
    DataFormTextStyle

    The default value of TextColor is Microsoft.Maui.Graphics.Colors.Red, FontSize is 12, FontFamily is null, FontAttributes is Microsoft.Maui.Controls.FontAttributes.None.

    Remarks

    The ErrorLabelTextStyle property takes precedence when explicitly defined.

    Examples

    The below examples shows, how to set the ErrorLabelTextStyle to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
     var errorLabelTextStyle = new DataFormTextStyle()
     {
       TextColor = Colors.Orange,
       FontSize = 14,
     };
     this.dataForm.ErrorLabelTextStyle = errorLabelTextStyle;
    See Also
    DataObject
    Items
    EditorTextStyle
    LabelTextStyle
    ValidMessageLabelTextStyle

    GroupHeaderTemplate

    Gets or sets the group header template.

    Declaration
    public DataTemplate GroupHeaderTemplate { get; set; }
    Property Value
    Type
    Microsoft.Maui.Controls.DataTemplate

    IsReadOnly

    Gets or sets a value indicating whether editors are enabled for editing.

    Declaration
    public bool IsReadOnly { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false.

    Remarks

    The IsReadOnly property takes precedence when explicitly defined. By setting IsReadOnly in AutoGenerating DataFormItem, editors can be enabled or disabled for a specific item.

    Examples

    The below examples shows, how to set the IsReadOnly to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         IsReadOnly="True">
    </dataForm:SfDataForm>
    this.dataForm.IsReadOnly = true;
    See Also
    Items
    DataObject
    IsReadOnly

    ItemManager

    Gets or sets the interface that provide method to get or set the value from or to the dictionary and customize the editor.

    Declaration
    public DataFormItemManager ItemManager { get; set; }
    Property Value
    Type
    DataFormItemManager
    Examples

    The below example shows, how to set ItemManger to the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    var dictionary = new Dictionary<string, object>();
    dictionary.Add("ID", 1);
    dictionary.Add("Name", "John");
    this.dataForm.AutoGenerateItems = false;
    var items = new ObservableCollection<DataFormViewItem>();
    foreach (var key in dictionary.Keys)
    {
        DataFormItem dataFormItem = null;
        if (key == "ID")
        {
            dataFormItem = new DataFormTextItem() { FieldName = key };
        }
        else if (key == "Name")
        {
            dataFormItem = new DataFormTextItem(  FieldName = key );
        }
        if (dataFormItem != null)
        {
            items.Add(dataFormItem);
        }
    }
    this.dataForm.Items = items;
    this.dataForm.ItemManager = new DataFormItemManagerExt(dictionary);
    public class DataFormItemManagerExt : IDataFormItemManager
    {
        Dictionary<string, object> dataFormDictionary;
        public DataFormItemManagerExt(Dictionary<string, object> dictionary)
        {
            dataFormDictionary = dictionary;
        }
        public override object GetValue(DataFormItem dataFormItem)
        {
            return dataFormDictionary[dataFormItem.FieldName];
        }
        public override void SetValue(DataFormItem dataFormItem, object value)
        {
            dataFormDictionary[dataFormItem.FieldName] = value;
        }
    }
    this.dataForm.ItemManager = new DataFormItemManagerExt();
    public class DataFormItemManagerExt : IDataFormItemManager
    {
        public override void InitializeDataEditor(DataFormItem dataFormItem, View editor)
        {
            if (editor is Entry entry)
            {
                entry.TextColor = Colors.Red;
            }
        }
    }

    Items

    Gets or sets the value which used to set the DataFormViewItem collection in the SfDataForm.

    Declaration
    public ObservableCollection<DataFormViewItem> Items { get; set; }
    Property Value
    Type
    System.Collections.ObjectModel.ObservableCollection<DataFormViewItem>
    Remarks

    The property is applicable to only when the AutoGenerateItems property is set to false.

    Examples

    The below examples shows, how to set the custom editors to the Items in the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         AutoGenerateItems="False">
     <dataForm:SfDataForm.Items>
        <dataForm:DataFormTextItem FieldName="First Name"/>
        <dataForm:DataFormTextItem FieldName="Last Name"/>
        <dataForm:DataFormTextItem FieldName="Contact Number"/>
        <dataForm:DataFormDateItem FieldName="Date of Birth"/>
        <dataForm:DataFormTextItem FieldName="Email"/>
        <dataForm:DataFormMultilineItem FieldName="Address"/>
      </dataForm:SfDataForm.Items>
    </dataForm:SfDataForm>
    this.dataForm.AutoGenerateItems = false;
    var items = new ObservableCollection<DataFormViewItem>();
    items.Add(new DataFormTextItem() { FieldName = "First Name" });
    items.Add(new DataFormTextItem() { FieldName = "Last Name" });
    items.Add(new DataFormTextItem() { FieldName = "Contact Number" });
    items.Add(new DataFormDateItem() { FieldName = "Date of Birth" });
    items.Add(new DataFormTextItem() { FieldName = "Email" });
    items.Add(new DataFormMultilineItem() { FieldName = "Address" });
    this.dataForm.Items = items;
    See Also
    AutoGenerateItems
    DataObject
    ItemsSourceProvider

    ItemsSourceProvider

    Gets or sets the value to get the source for picker type editors.

    Declaration
    public IDataFormSourceProvider ItemsSourceProvider { get; set; }
    Property Value
    Type Description
    IDataFormSourceProvider

    The default value is null.

    Examples

    The below examples shows, how to set the ItemsSourceProvider to the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding ContactsInfo}">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    public class ContactsInfo
    {
      public String Name { get; set; }
      public string City { get; set; }
    }
    this.dataForm.RegisterEditor(nameof(ContactInfo.City), DataFormEditorType.Picker);
    this.dataForm.ItemsSourceProvider = new ItemsSourceProvider();
    public class ItemsSourceProvider : IDataFormSourceProvider
    {
       public object GetSource(string sourceName)
       {
          List<string> groupNames = new List<string>
          {
              "Chennai",
              "Bengaluru",
              "Kolkota",
              "Delhi",
          };
          return groupNames;
       }
    }

    LabelTextStyle

    Gets or sets the style of label text, that used to customize the text color, font, font size, font family and font attributes.

    Declaration
    public DataFormTextStyle LabelTextStyle { get; set; }
    Property Value
    Type Description
    DataFormTextStyle

    The default value of TextColor is Microsoft.Maui.Graphics.Colors.Black, FontSize is 16, FontFamily is null, FontAttributes is Microsoft.Maui.Controls.FontAttributes.None.

    Remarks

    The LabelTextStyle property takes precedence when explicitly defined.

    Examples

    The below examples shows, how to set the LabelTextStyle to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
     var labelTextStyle = new DataFormTextStyle()
     {
       TextColor = Colors.Orange,
       FontSize = 14,
     };
     this.dataForm.LabelTextStyle = labelTextStyle;
    See Also
    DataObject
    Items
    EditorTextStyle
    ErrorLabelTextStyle
    ValidMessageLabelTextStyle

    LayoutType

    Gets or sets layout option.

    Declaration
    public DataFormLayoutType LayoutType { get; set; }
    Property Value
    Type Description
    DataFormLayoutType

    The default value isDefault.

    Examples

    The below example shows, how to set LayoutType to the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         LayoutType="Default"
                         DataObject="{Binding ContactsInfo}">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    public class ContactsInfo
    {
      public String Name { get; set; }
      public string City { get; set; }
    }
    this.dataForm.LayoutType = DataFormLayoutType.Default;

    TextInputLayoutSettings

    Gets or sets text input layout settings.

    Declaration
    public TextInputLayoutSettings TextInputLayoutSettings { get; set; }
    Property Value
    Type Description
    TextInputLayoutSettings

    The default value of ContainerType is Outlined and ShowHelperText is true.

    Remarks

    The TextInputLayoutSettings is applicable only when LayoutType or LayoutType is TextInputLayout. The TextInputLayoutSettings property takes precedence when explicitly defined.

    Examples

    The below example shows, how to set TextInputLayoutSettings to the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         LayoutType="TextInputLayout"
                         DataObject="{Binding ContactsInfo}">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
        <dataForm:SfDataForm.TextInputLayoutSettings>
            <dataForm:TextInputLayoutSettings
                ContainerType="Outlined"/>
        </dataForm:SfDataForm.TextInputLayoutSettings>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    public class ContactsInfo
    {
      public String Name { get; set; }
      public string City { get; set; }
    }
    this.dataForm.LayoutType = DataFormLayoutType.TextInputLayout;
    this.dataForm.TextInputLayoutSettings = new TextInputLayoutSettings { ContainerType = TextInputLayoutContainerType.Outlined };
    See Also
    AutoGenerateItems
    DataObject

    ValidationMode

    Gets or sets a value that denotes when the user input should be validated based on IDataErrorInfo and ValidationAttributes.

    Declaration
    public DataFormValidationMode ValidationMode { get; set; }
    Property Value
    Type Description
    DataFormValidationMode

    The default value is LostFocus.

    Remarks

    The ValidationMode property specifies when the data form validates the user input. The following modes are supported:

    • The LostFocus — the form validates a data field when an editor loses focus.
    • The PropertyChanged — the form validates a data field when its value changes.
    • The Manual — the form validates data fields when the Validate() method is called. You can also call the Validate(List<String>) method to validate a specific data field.
    >
    Examples

    The below examples shows, how to set the ValidationMode to the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         ValidationMode="PropertyChanged"
                         DataObject="{Binding ContactsInfo}">
       <dataForm:SfDataForm.BindingContext>
           <local:DataFormViewModel />
       </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public ContactsInfo ContactsInfo { get;set; }
    }
    public class ContactsInfo
    {
       public string FirstName { get; set; }
       public string LastName { get; set; }
       public string ContactNumber { get; set; }
       public string Email { get; set; }
       public string Address { get; set; }
    }
    this.dataForm.ValidationMode = DataFormValidationMode.PropertyChanged;
    this.dataForm.DataObject = new DataFormViewModel().ContactsInfo;

    ValidMessageLabelTextStyle

    Gets or sets the style of validation label text, that used to customize the text color, font, font size, font family and font attributes.

    Declaration
    public DataFormTextStyle ValidMessageLabelTextStyle { get; set; }
    Property Value
    Type Description
    DataFormTextStyle

    The default value of TextColor is Microsoft.Maui.Graphics.Colors.Green, FontSize is 12, FontFamily is null, FontAttributes is Microsoft.Maui.Controls.FontAttributes.None.

    Remarks

    The ValidMessageLabelTextStyle property takes precedence when explicitly defined.

    Examples

    The below examples shows, how to set the ValidMessageLabelTextStyle to the SfDataForm.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
     var validMessageLabelTextStyle = new DataFormTextStyle()
     {
       TextColor = Colors.Blue,
       FontSize = 14,
     };
     this.dataForm.ValidMessageLabelTextStyle = validMessageLabelTextStyle;
    See Also
    DataObject
    Items
    EditorTextStyle
    LabelTextStyle
    ErrorLabelTextStyle

    Methods

    Commit()

    Method to commit all properties underlying data object from the editor view.

    Declaration
    public void Commit()
    Examples

    The below examples shows, how to set the Commit method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    this.dataForm.Commit();
    See Also
    CommitMode

    GetDataFormGroupItem(String)

    Gets the DataFormGroupItem.

    Declaration
    public DataFormGroupItem GetDataFormGroupItem(string groupName)
    Parameters
    Type Name Description
    System.String groupName

    The group name.

    Returns
    Type Description
    DataFormGroupItem

    The DataFormGroupItem with specified group name.

    Examples

    The below examples shows, how to set the GetDataFormGroupItem method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    DataFormGroupItem groupItem = this.dataForm.GetDataFormGroupItem("SignIn");
    See Also
    Items

    GetDataFormItem(String)

    Gets the DataFormItem.

    Declaration
    public DataFormItem GetDataFormItem(string propertyName)
    Parameters
    Type Name Description
    System.String propertyName

    The property name.

    Returns
    Type Description
    DataFormItem

    The DataFormItem with specified property name.

    Examples

    The below examples shows, how to set the GetDataFormItem method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    DataFormItem item = this.dataForm.GetDataFormItem("First Name");
    See Also
    Items

    MeasureContent(Double, Double)

    This method will invoke on measure.

    Declaration
    protected override Size MeasureContent(double widthConstraint, double heightConstraint)
    Parameters
    Type Name Description
    System.Double widthConstraint

    The width.

    System.Double heightConstraint

    The height.

    Returns
    Type Description
    Microsoft.Maui.Graphics.Size

    The size.

    Overrides
    SfView.MeasureContent(Double, Double)

    OnBindingContextChanged()

    Invokes on the binding context of the view changed.

    Declaration
    protected override void OnBindingContextChanged()
    Overrides
    SfView.OnBindingContextChanged()

    RegisterEditor(String, DataFormEditorType)

    Registers editor for property name.

    Declaration
    public void RegisterEditor(string propertyName, DataFormEditorType editor)
    Parameters
    Type Name Description
    System.String propertyName

    The propertyName to have editor.

    DataFormEditorType editor

    The editor that loaded for property name.

    Examples

    The below examples shows, how to set the RegisterEditor method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    this.dataForm.RegisterEditor(nameof(ContactInfo.City), DataFormEditorType.Picker);
    See Also
    ItemsSourceProvider

    RegisterEditor(String, IDataFormEditor)

    Registers editor for custom editor.

    Declaration
    public void RegisterEditor(string propertyName, IDataFormEditor editor)
    Parameters
    Type Name Description
    System.String propertyName

    The propertyName to have editor.

    IDataFormEditor editor

    The custom editor that loaded for property name.

    Examples

    The below examples shows, how to set the RegisterEditor method to the data form.

    • XAML
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    this.dataForm.RegisterEditor(nameof(ContactInfo.Name), new CustomSignaturePadEditor());
    public class CustomSignaturePadEditor : IDataFormEditor
    {
      private DataFormItem? dataFormItem;
       public void CommitValue(DataFormItem dataFormItem, View view)
       {
           dataFormItem.SetValue(((SfSignaturePad)view).ToImageSource());
       }
       public View CreateEditorView(DataFormItem dataFormItem)
       {
           Border border = new Border();
           SfSignaturePad signaturePadEditor = new SfSignaturePad();
           signaturePadEditor.DrawCompleted += this.OnSignaturePadEditorDrawCompleted;
           border.HeightRequest = 180;
           border.Content = signaturePadEditor;
           border.Stroke = Brush.LightGray;
           border.StrokeThickness = 1;
           border.StrokeShape = new RoundRectangle() { CornerRadius = 5 };
           this.dataFormItem = dataFormItem;
           return border;
       }
       public void UpdateReadyOnly(DataFormItem dataFormItem)
       {
       }
       private void OnSignaturePadEditorDrawCompleted(object? sender, EventArgs e)
       {
           if (sender is SfSignaturePad signaturePad)
               this.CommitValue(this.dataFormItem!, signaturePad);
       }
    }
    See Also
    ItemsSourceProvider

    RegisterEditor(Type, DataFormEditorType)

    Registers editor for property type.

    Declaration
    public void RegisterEditor(Type type, DataFormEditorType editor)
    Parameters
    Type Name Description
    System.Type type

    The type to have editor.

    DataFormEditorType editor

    The editor that loaded for type.

    Examples

    The below examples shows, how to set the RegisterEditor method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    this.dataForm.RegisterEditor(nameof(ContactInfo.City, DataFormEditorType.Picker);
    See Also
    ItemsSourceProvider

    ScrollTo(String)

    Scrolls to specific editor in data form.

    Declaration
    public void ScrollTo(string fieldName)
    Parameters
    Type Name Description
    System.String fieldName

    The name of the editor field.

    UpdateEditor(String)

    Updates the value of the specific property in corresponding editor.

    Declaration
    public void UpdateEditor(string propertyName)
    Parameters
    Type Name Description
    System.String propertyName

    The property name.

    Validate()

    Validates all the fields of Items.

    Declaration
    public bool Validate()
    Returns
    Type Description
    System.Boolean

    True if all the fields are valid, otherwise false.

    Examples

    The below examples shows, how to set the Validate method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    this.dataForm.Validate();
    See Also
    ValidationMode

    Validate(List<String>)

    Validates the specified properties.

    Declaration
    public bool Validate(List<string> propertyName)
    Parameters
    Type Name Description
    System.Collections.Generic.List<System.String> propertyName

    The list of property names.

    Returns
    Type Description
    System.Boolean

    True if all the specified fields are valid, otherwise false.

    Examples

    The below examples shows, how to set the Validate method to the data form.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    List<string> strings = new List<string>();
    strings.Add("FirstName");
    strings.Add("LastName");
    this.dataForm.Validate(strings);
    See Also
    ValidationMode

    Events

    GenerateDataFormItem

    Occurs during the generation of data form item in the data form when AutoGenerateItems is true.

    Declaration
    public event EventHandler<GenerateDataFormItemEventArgs> GenerateDataFormItem
    Event Type
    Type
    System.EventHandler<GenerateDataFormItemEventArgs>
    Examples

    The following code demonstrates, how to use the SfDataForm's generate data form item event.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         AutoGenerateItems="True"
                         GenerateDataFormItem="OnDataFormGenerateDataFormItem">
    </dataForm:SfDataForm>
    this.dataForm.GenerateDataFormItem += this.OnDataFormGenerateDataFormItem;
    private void OnDataFormGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e)
    {
       if (e.DataFormItem != null)
           e.Cancel = true;
    }
    See Also
    DataObject
    Items
    ItemsSourceProvider
    AutoGenerateItems
    ColumnCount

    ValidateForm

    Occurs when Manual to get the invalid DataFormItem’s details.

    Declaration
    public event EventHandler<DataFormValidateFormEventArgs> ValidateForm
    Event Type
    Type
    System.EventHandler<DataFormValidateFormEventArgs>
    Examples

    The following code demonstrates, how to use the SfDataForm's validate form event.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         ValidateForm="OnDataFormValidateForm">
    </dataForm:SfDataForm>
    this.dataForm.ValidateForm += this.OnDataFormValidateForm;
    private void OnDataFormValidateForm(object sender, DataFormValidateFormEventArgs e)
    {
       object dataObject = e.DataObject;
       var errorMessage = e.ErrorMessage;
    }
    See Also
    DataObject
    Items
    ItemsSourceProvider
    AutoGenerateItems
    ColumnCount

    ValidateProperty

    Occurs when SfDataForm validates the user input.

    Declaration
    public event EventHandler<DataFormValidatePropertyEventArgs> ValidateProperty
    Event Type
    Type
    System.EventHandler<DataFormValidatePropertyEventArgs>
    Examples

    The following code demonstrates, how to use the SfDataForm's validate property event.

    • XAML
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         AutoGenerateItems="True"
                         ValidateProperty="OnDataFormValidateProperty">
    </dataForm:SfDataForm>
    this.dataForm.ValidateProperty += this.OnDataFormValidateProperty;
    private void OnDataFormValidateProperty(object sender, DataFormValidatePropertyEventArgs e)
    {
       bool isValid = e.IsValid;
       string propertyName = e.PropertyName;
    }
    See Also
    DataObject
    Items
    ItemsSourceProvider
    AutoGenerateItems
    ColumnCount

    Implements

    IDrawableLayout
    Microsoft.Maui.Graphics.IDrawable
    Microsoft.Maui.IAbsoluteLayout
    Microsoft.Maui.ILayout
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IContainer
    System.Collections.Generic.IList<>
    System.Collections.Generic.ICollection<>
    System.Collections.Generic.IEnumerable<>
    System.Collections.IEnumerable
    Microsoft.Maui.ISafeAreaView
    Microsoft.Maui.IPadding
    Microsoft.Maui.ICrossPlatformLayout
    Microsoft.Maui.IVisualTreeElement
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved