Skip to main content

Labels in DevExpress Data Form for .NET MAUI

  • 3 minutes to read

A label describes the purpose of the input field and guides users to enter relevant information. You can specify and configure the following labels:

DevExpress Data Form for MAUI - All labels

Regular Labels

The data form can display strings or icons as labels next to the editor.

DevExpress Data Form for MAUI - Labels

The following code snippet displays and configures labels that appear above editors:

<ContentPage ...
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors" >
    <dxdf:DataFormView x:Name="dataForm">
        <dxdf:DataFormTextItem FieldName="LastName" 
                        LabelIcon="Person"
                        ... />
        <dxdf:DataFormDateItem FieldName="BirthDate" 
                        IsLabelVisible="True"
                        LabelText="Birth Date" 
                        LabelFontSize="18"
                        LabelFontAttributes="Italic"
                        LabelFontFamily="Times New Roman"
                        LabelIndent="15"
                        LabelColor="Green"
                        LabelPosition="Top"
                        LabelHorizontalAlignment="Start"
                        LabelWidth="90"
                        LabelMinWidth="20"
                        LabelMaxWidth="150"
                        ... />
    </dxdf:DataFormView>
</ContentPage>

Floating Labels

A floating label is a caption that informs users about the editor’s purpose.

DevExpress Data Form for MAUI - Floating Labels

Use the InplaceLabelText property to specify the floating label text.

When an editor does not have input focus, the label is used as a placeholder. Once the editor gets focus, the label floats above the input field. If you want to disable the floating label effect, set the IsInplaceLabelFloating property to false.

The following code snippet displays a floating label:

<ContentPage ...
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors" >
    <dxdf:DataFormView x:Name="dataForm">
        <dxdf:DataFormTextItem FieldName="LastName" 
                        InplaceLabelText="First Name"
                        IsInplaceLabelFloating="True"
                        ... />
    </dxdf:DataFormView>
</ContentPage>

Assistive Labels

You can specify and configure assistive labels that appear below the editor.

DevExpress Data Form for MAUI - Assistive Labels

The following code snippet displays and configures an assistive message:

<ContentPage ...
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors" >
    <dxdf:DataFormView x:Name="dataForm">
        <dxdf:DataFormDateItem FieldName="BirthDate" 
                        HelpText="Select your birth date"
                        HelpTextColor="Green"
                        BottomTextFontSize="18"
                        BottomTextFontAttributes="Italic"
                        BottomTextFontFamily="Times New Roman"
                        ... />
    </dxdf:DataFormView>
</ContentPage>

Use the HelpText property to specify the help message.

If HelpText is not set, an error message may shift page content down when it appears. To prevent this behavior, set the ReserveBottomTextLine property to true.

To specify the color of the error message, error icon, editor’s borders, and in-place label in the error state, use the ErrorColor property.

DevExpress Data Form for MAUI - Error Color

Refer to the following topic for more information: Validate User Input in Data Form for .NET MAUI.

Affixed Labels

You can specify labels displayed before and after the input string within an editor. For this purpose, use Prefix and Suffix properties.

DevExpress Data Form for MAUI - Affixed Labels

The following code snippet displays affixed labels:

<ContentPage ...
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors" >
    <dxdf:DataFormView x:Name="dataForm">
        <dxdf:DataFormTextItem FieldName="Email" 
                        Suffix="@dx-email.com"
                        ... />
        <dxdf:DataFormNumericItem FieldName="Email" 
                        Prefix="$"
                        ... />
    </dxdf:DataFormView>
</ContentPage>

Common Label Settings

The DataFormView control includes APIs that allow you to change label appearance for all editors on the form:

<ContentPage ...
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors">
    <dxdf:DataFormView x:Name="dataForm" ...
                    IsEditorLabelVisible="True"
                    EditorLabelFontSize="18"
                    EditorLabelFontAttributes="Italic"
                    EditorLabelFontFamily="Times New Roman"
                    EditorLabelColor="Green"
                    EditorLabelPosition="Top"
                    EditorLabelHorizontalAlignment="Start"
                    EditorLabelIndent="15"
                    EditorLabelWidth="30"
                    EditorLabelMinWidth="20"
                    EditorLabelMaxWidth="60" 
                    ... />
</ContentPage>

Label Attributes

You can use parameters of the DataFormDisplayOptions attribute to configure labels for an individual editor:

<ContentPage ...
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors">
    <dxdf:DataFormView x:Name="dataForm" ... />
</ContentPage>
namespace DataFormExample {
    public class PersonalInfo {
        [DataFormDisplayOptions(
            LabelIcon = "Person",
            ...
        )]
        public string FirstName { get; set; }
        public string LastName { get; set; }

        [DataFormDisplayOptions(
            IsLabelVisible = true,
            LabelText = "Birth Date",
            LabelIndent = 15,
            LabelWidth = 30,
            LabelMinWidth = 20,
            LabelMaxWidth = 60,
            LabelPosition = "Top",
            LabelHorizontalAlignment = "Start"
        )]
        public DateTime BirthDate { get; set; }

        public virtual Gender Gender { get; set; }
        public string Password { get; set; }
        ...
    }
    public enum Gender { Female, Male, RatherNotSay }
}