menu

Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfDataForm - Xamarin.Forms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfDataForm

    DataForm control provides UI for editing all the public properties of data object with appropriate editors based on type of property.
    DataForm control provides options to control editing, validation of data and customization of layout.

    Inheritance
    System.Object
    SfDataForm
    Implements
    System.IDisposable
    Namespace: Syncfusion.XForms.DataForm
    Assembly: Syncfusion.SfDataForm.XForms.dll
    Syntax
    public class SfDataForm : View, IParentThemeElement, IThemeElement, IDisposable

    Constructors

    SfDataForm()

    Initializes a new instance of the SfDataForm class.

    Declaration
    public SfDataForm()

    Fields

    AutoGenerateItemsProperty

    Identifies the AutoGenerateItems bindable property.

    Declaration
    public static readonly BindableProperty AutoGenerateItemsProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ColumnCountProperty

    Identifies the ColumnCount bindable property.

    Declaration
    public static readonly BindableProperty ColumnCountProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    CommitModeProperty

    Identifies the CommitMode bindable property.

    Declaration
    public static readonly BindableProperty CommitModeProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    DataObjectProperty

    Identifies the DataObject bindable property.

    Declaration
    public static readonly BindableProperty DataObjectProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    EditorWidthProperty

    Identifies the EditorWidth bindable property.

    Declaration
    public static readonly BindableProperty EditorWidthProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    IsReadOnlyProperty

    Identifies the IsReadOnly bindable property.

    Declaration
    public static readonly BindableProperty IsReadOnlyProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ItemsProperty

    Identifies the Items bindable property.

    Declaration
    public static readonly BindableProperty ItemsProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    LabelPositionProperty

    Identifies the LabelPosition bindable property.

    Declaration
    public static readonly BindableProperty LabelPositionProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    LabelWidthProperty

    Identifies the LabelWidth bindable property.

    Declaration
    public static readonly BindableProperty LabelWidthProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    NotifyPropertyChangesProperty

    Identifies the NotifyPropertyChanges bindable property.

    Declaration
    public static readonly BindableProperty NotifyPropertyChangesProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is NotifyPropertyChanges.

    ValidationModeProperty

    Identifies the ValidationMode bindable property.

    Declaration
    public static readonly BindableProperty ValidationModeProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ValidationTemplateProperty

    The validation template property.

    Declaration
    public static readonly BindableProperty ValidationTemplateProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    Properties

    AutoGenerateItems

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

    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 false/>.

    ColumnCount

    Gets or sets the value denotes the number of editor to be arranged per row. Be default one editor for one property arranged with label.

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

    The default value is one.

    CommitMode

    Gets or sets the value that determines, when the value entered by user should be saved to the data object.

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

    The commit mode.

    ContainerBackgroundColor

    Gets or sets the container background color for dataform to define the container background color of dataform items within the textinputlayout.

    Declaration
    public Color ContainerBackgroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    The default value is Xamarin.Forms.Color.Default.

    Remarks

    Applicable only for the Dataform which TextInputLayout.

    ContainerType

    Gets or sets the container type for dataform to define the container type of dataform item within the textinputlayout.

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

    The default value is Outlined.

    Remarks

    Applicable only for the Dataform which TextInputLayout.

    DataObject

    Gets or sets a data object to view or edit the properties. DataForm generates the editors and labels from the public properties of data object.

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

    EditorWidth

    Gets or sets the value that splits the width for editor from DataFormItemView.

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

    The width of the editor.

    IsReadOnly

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

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

    The default value is false.

    Remarks

    IsReadOnly takes higher priority when explicit defined. Editors can be enabled or disabled for particular property by setting IsReadOnly in AutoGeneratingDataFormItem. Editors can be enabled or disabled for particular property by setting System.ComponentModel.DataAnnotations.EditableAttribute.AllowEdit.

    ItemManager

    Gets or sets the item manager.

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

    The item manager.

    Items

    Gets or sets the custom DataFormItemBase collection in SfDataForm.

    Declaration
    public ObservableCollection<DataFormItemBase> Items { get; set; }
    Property Value
    Type
    System.Collections.ObjectModel.ObservableCollection<DataFormItemBase>
    Examples
    SfDataForm dataForm = new SfDataForm();
    var items = new ObservableCollection<DataFormItemBase>();
    items.Add(new DataFormTextItem() { Name = "First", Editor = "Text" });
    items.Add(new DataFormTextItem() { Name = "Password", Editor = "Password" });
    dataForm.AutoGenerateItems = false;
    dataForm.Items = items;
    this.Content = dataForm;

    LabelPosition

    Gets or sets the value denotes how to layout the label associated with editor. Label's can be positioned either at the top or left side of editor.

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

    The default value is Left.

    LabelWidth

    Gets or sets the value that splits the width for label from DataFormItemView.

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

    The width of the label.

    LayoutManager

    Gets or sets the layout manager.

    Declaration
    public DataFormLayoutManager LayoutManager { get; set; }
    Property Value
    Type Description
    DataFormLayoutManager

    The layout manager.

    LayoutOptions

    Gets or sets the layout options for DataForm to define the layout type for the DataFormItem in dataform.

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

    The default value is Default.

    Remarks

    Not appicable to radiogroup, segment, dropdown, switch and checkbox editors.

    NotifyPropertyChanges

    Gets or sets a value indicating whether DataObject property value changes has to be notify if DataObject is implement form INotifyPropertyChanged interface.

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

    The default value is false.

    Remarks

    Property value changes done in DataObject which has been implemented from INotifyPropertyChanged can be notified by setting NotifyPropertyChanges true/>.

    ShowHelperText

    Gets or sets a value indicating whether dataform to show the helper text label in textinputlayout.

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

    true To show helper text; otherwise, false.

    Remarks

    Applicable only for the Dataform which TextInputLayout.

    SourceProvider

    Gets or sets the reference to the SourceProvider instance which is used to get the source for picker type editors.

    Declaration
    public SourceProvider SourceProvider { get; set; }
    Property Value
    Type
    SourceProvider

    ValidationMode

    Gets or sets a value that denotes when the user input should be validated based on IDataErrorInfo and System.ComponentModel.DataAnnotations.ValidationAttribute.

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

    One of the ValidationMode enum. The default value is LostFocus.

    Remarks

    The SfDataForm process the built-in validations when data object implements IDataErrorInfo or property defined with System.ComponentModel.DataAnnotations.ValidationAttribute. The validation can be performed explicitly by handling Validating.

    ValidationTemplate

    Gets or sets the template for validation view.

    Declaration
    public DataTemplate ValidationTemplate { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.DataTemplate

    The validation template.

    Methods

    CollapseGroup(String)

    Collapse group by group name.

    Declaration
    public void CollapseGroup(string groupName)
    Parameters
    Type Name Description
    System.String groupName

    The name of the group.

    Commit()

    Commits all property values in data form items.

    Declaration
    public void Commit()

    Commit(String)

    Commits the value of the specific property.

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

    Property name.

    Dispose()

    Releases all resource used by the SfDataForm object.

    Declaration
    public void Dispose()
    Remarks

    Call Dispose() when you are finished using the SfDataForm. The Dispose() method leaves the SfDataForm in an unusable state. After calling Dispose(), you must release all references to the SfDataForm so the garbage collector can reclaim the memory that the SfDataForm was occupying.

    Dispose(Boolean)

    Dispose the specified isDisposing.

    Declaration
    protected virtual void Dispose(bool isDisposing)
    Parameters
    Type Name Description
    System.Boolean isDisposing

    If set to true is disposing.

    ExpandGroup(String)

    Expands group by group name.

    Declaration
    public void ExpandGroup(string groupName)
    Parameters
    Type Name Description
    System.String groupName

    The name of the group.

    GetGroupCollapseIcon()

    Gets the Resource ID from the Android resources for the group collapse icon.

    Declaration
    public virtual ImageSource GetGroupCollapseIcon()
    Returns
    Type Description
    Xamarin.Forms.ImageSource

    The group collapse icon.

    GetGroupExpanderIcon()

    Gets the Resource ID from the Android resources for group expander icon.

    Declaration
    public virtual ImageSource GetGroupExpanderIcon()
    Returns
    Type Description
    Xamarin.Forms.ImageSource

    The group expander icon.

    RefreshLayout(Boolean)

    Loads more fields when the user wants to generate the fields that was canceled.

    Declaration
    public void RefreshLayout(bool generateAllItems = false)
    Parameters
    Type Name Description
    System.Boolean generateAllItems

    True to regenerate all the items from the committed data object. false only generate the field that was canceled initially.

    RegisterEditor(String, DataFormEditorBase)

    Register a customzied editor.

    Declaration
    public void RegisterEditor(string editorName, DataFormEditorBase dataFormEditor)
    Parameters
    Type Name Description
    System.String editorName

    Editor name.

    DataFormEditorBase dataFormEditor

    Editor.

    RegisterEditor(String, String)

    Registers editor for property name.

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

    The propertyName to have editor.

    System.String editor

    The editor that loaded for property name.

    RegisterEditor(Type, String)

    Registers editor for property type.

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

    The type to have editor.

    System.String editor

    The editor that loaded for type.

    ScrollTo(String)

    Scrolls to specific editor in dataform.

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

    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 to be updated.

    Validate()

    Validates all property values of data form items.

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

    Returns True if all the properties in DataForm are valid otherwise False.

    Validate(String)

    Validates the value of the specific property.

    Declaration
    public bool Validate(string propertyName)
    Parameters
    Type Name Description
    System.String propertyName

    The property to be validated.

    Returns
    Type Description
    System.Boolean

    Returns True if the property is valid otherwise false.

    Events

    AutoGeneratingDataFormItem

    Occurs during generation of data form item.

    Declaration
    public event EventHandler<AutoGeneratingDataFormItemEventArgs> AutoGeneratingDataFormItem
    Event Type
    Type
    System.EventHandler<AutoGeneratingDataFormItemEventArgs>

    GroupItemCollapsed

    Occurs when group gets collapsed by user.

    Declaration
    public event EventHandler<GroupItemCollapsedEventArgs> GroupItemCollapsed
    Event Type
    Type
    System.EventHandler<GroupItemCollapsedEventArgs>

    GroupItemCollapsing

    Occurs when user try collapse a group. You can cancel the user action using this event.

    Declaration
    public event EventHandler<GroupItemCollapsingEventArgs> GroupItemCollapsing
    Event Type
    Type
    System.EventHandler<GroupItemCollapsingEventArgs>
    Remarks

    You can cancel the user action by using GroupItemCollapsingEventArgs.

    GroupItemExpanded

    Occurs when group expanded by user.

    Declaration
    public event EventHandler<GroupItemExpandedEventArgs> GroupItemExpanded
    Event Type
    Type
    System.EventHandler<GroupItemExpandedEventArgs>

    GroupItemExpanding

    Occurs when user try expand a group. You can cancel the user action using this event.

    Declaration
    public event EventHandler<GroupItemExpandingEventArgs> GroupItemExpanding
    Event Type
    Type
    System.EventHandler<GroupItemExpandingEventArgs>
    Remarks

    You can cancel the user action by using GroupItemExpandingEventArgs.

    Validated

    Occurs after completion of user input validation.

    Declaration
    public event EventHandler<ValidatedEventArgs> Validated
    Event Type
    Type
    System.EventHandler<ValidatedEventArgs>

    Validating

    Occurs when SfDataForm validates the user input.

    Declaration
    public event EventHandler<ValidatingEventArgs> Validating
    Event Type
    Type
    System.EventHandler<ValidatingEventArgs>

    ValidationCompleted

    Occurs when Explicit to get the invalid DataFormItems details.

    Declaration
    public event EventHandler<ValidationCompletedEventArgs> ValidationCompleted
    Event Type
    Type
    System.EventHandler<ValidationCompletedEventArgs>

    Implements

    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved