MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class DataFormDisplayOptionsAttribute

    Show / Hide Table of Contents

    Class DataFormDisplayOptionsAttribute

    Provides a attribute that lets you specify the display settings for a data field.

    Inheritance
    System.Object
    DataFormDisplayOptionsAttribute
    Namespace: Syncfusion.Maui.DataForm
    Assembly: Syncfusion.Maui.DataForm.dll
    Syntax
    public sealed class DataFormDisplayOptionsAttribute : Attribute

    Constructors

    DataFormDisplayOptionsAttribute()

    Initializes a new instance of the DataFormDisplayOptionsAttribute class.

    Declaration
    public DataFormDisplayOptionsAttribute()

    Properties

    ColumnSpan

    Gets or sets the number of column that this item spans to increase item's width.

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

    The default value is 1.

    Remarks

    Data form editors are arranged in rows, use the RowOrder property to specify the row order where the editor should be displayed.

    Examples

    The below examples shows, how to set the ColumnSpan property of DataFormDisplayOptionsAttribute in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding AccountInfo}">
      <dataForm:SfDataForm.BindingContext>
        <local:DataFormViewModel/>
      </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public AccountInfo AccountInfo { get;set; }
    }
    public class AccountInfo
    {
       [DisplayOptionsAttribute(ColumnSpan = 2)]
       public string UserName { get; set; }
       [DisplayOptionsAttribute(ColumnSpan = 2)]
       [DataType(DataType.Password)]
       public string Password { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().AccountInfo;

    ItemsOrderInRow

    Gets or sets the editor’s position in a row.

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

    The default value is -1.

    Remarks

    This property is applicable to only when the ColumnCount is greater than 1. The items on the data form are arranged in layout rows. Use the RowOrder property to specify the number of the layout row where the item should be displayed. Use the ItemsOrderInRow property to display multiple editors in a single row. Two items with the same RowOrder property value are placed in this row according to their ItemOrderInRow property values.

    Examples

    The below examples shows, how to set the ItemsOrderInRow property of DataFormDisplayOptionsAttribute in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding AccountInfo}">
      <dataForm:SfDataForm.BindingContext>
        <local:DataFormViewModel/>
      </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
        public AccountInfo AccountInfo { get;set; }
    }
    public class AccountInfo
    {
       [DisplayOptionsAttribute(ItemsOrderInRow = 0)]
       public string UserName { get; set; }
       [DataType(DataType.Password)]
       [DisplayOptionsAttribute(ItemsOrderInRow = 1)]
       public string Password { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().AccountInfo;

    RowOrder

    Gets or sets the row order of the editor in the data form.

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

    The default value is -1.

    Remarks

    Items on the data form are arranged in layout rows and columns. Use the RowOrder property to specify the number of the layout row where the item should be displayed.

    Examples

    The below examples shows, how to set the RowOrder property of DataFormDisplayOptionsAttribute in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding AccountInfo}">
      <dataForm:SfDataForm.BindingContext>
        <local:DataFormViewModel/>
      </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>>
    public class DataFormViewModel
    {
       public AccountInfo AccountInfo { get;set; }
    }
    public class AccountInfo
    {
       [DataType(DataType.Password)]
       [DisplayOptionsAttribute(RowOrder = 2)]
       public string Password { get; set; }
       [DisplayOptionsAttribute(RowOrder = 1)]
       public string UserName { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().AccountInfo;

    RowSpan

    Gets or sets the number of rows that this item spans which is used to increase item's height.

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

    The default value is 1.

    Remarks

    Data form editors are arranged in rows, use the RowOrder property to specify the row order where the editor should be displayed.

    Examples

    The below examples shows, how to set the RowSpan property of DataFormDisplayOptionsAttribute in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding AccountInfo}">
      <dataForm:SfDataForm.BindingContext>
        <local:DataFormViewModel/>
      </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
        public AccountInfo AccountInfo { get;set; }
    }
    public class AccountInfo
    {
       [DisplayOptionsAttribute(RowSpan = 2)]
       public string UserName { get; set; }
       [DisplayOptionsAttribute(RowSpan = 2)]
       [DataType(DataType.Password)]
       public string Password { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().AccountInfo;

    ShowLabel

    Gets or sets a value indicating whether to show the label to the DataForm editor.

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

    The default value is true.

    Examples

    The below examples shows, how to set the ShowLabel property of DataFormDisplayOptionsAttribute in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm"
                         DataObject="{Binding AccountInfo}">
      <dataForm:SfDataForm.BindingContext>
        <local:DataFormViewModel/>
      </dataForm:SfDataForm.BindingContext>
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
       public AccountInfo AccountInfo { get;set; }
    }
    public class AccountInfo
    {
       [DisplayOptionsAttribute(ShowLabel = false)]
       public string UserName { get; set; }
       [DisplayOptionsAttribute(ShowLabel = false)]
       [DataType(DataType.Password)]
       public string Password { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().AccountInfo;

    ValidMessage

    Gets or sets a string which will get displayed when user enters valid value for the data field as success message.

    Declaration
    public string ValidMessage { get; set; }
    Property Value
    Type Description
    System.String
    Examples

    The below examples shows, how to set the ValidMessage property of DataFormDisplayOptionsAttribute in the SfDataForm.

    • XAML
    • C#
    • C#
    • C#
    • C#
    <dataForm:SfDataForm x:Name="dataForm">
    </dataForm:SfDataForm>
    public class DataFormViewModel
    {
        public AccountInfo AccountInfo { get;set; }
    }
    public class AccountInfo
    {
       [EmailAddress(ErrorMessage = "Please enter your email")]
       [DisplayOptionsAttribute(ValidMessage ="Username is correct")]
       public string UserName { get; set; }
       [Required(ErrorMessage = "Please enter the password")]
       [RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z\d]{8,}$", ErrorMessage = "A minimum 8-character password should contain a combination of uppercase and lowercase letters.")]
       [DisplayOptionsAttribute(ValidMessage ="Password is correct")]
       [DataType(DataType.Password)]
       public string Password { get; set; }
    }
    this.dataForm.DataObject = new DataFormViewModel().AccountInfo;
    this.dataForm.AutoGenerateItems = false;
    var items = new ObservableCollection<DataFormViewItem>();
    items.Add(new DataFormTextItem() { FieldName = "UserName" });
    items.Add(new DataFormPasswordItem() { FieldName = "Password" });
    this.dataForm.Items = items;
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved