Skip to main content

DataFormDateItem.DisplayFormat Property

Gets or sets the pattern used to format the editor’s value.

Namespace: DevExpress.Maui.DataForm

Assembly: DevExpress.Maui.Editors.dll

NuGet Package: DevExpress.Maui.Editors

Declaration

public string DisplayFormat { get; set; }

Property Value

Type Default Description
String D

The text pattern for the editor’s value.

Remarks

Use the DisplayFormat property to format the editor’s date-time value and add additional text. The pattern has the following structure:

<custom static text>{0:<format specifier>}<custom static text>

  • {0} – the value’s placeholder.
  • format specifier – the format type.

Refer to the following pages for more information about format specifiers:

If you do not need to display extra text with the formatted date, you can specify a date-time format specifier only in the format string (for instance, “d”).

In XAML, insert empty brackets at the beginning of a pattern if it starts with a placeholder. Refer to the following page for more information: {} Escape sequence / markup extension.

Example

The following example shows how to format input dates in the Data Form’s date-time editor:

DevExpress MAUI DataForm - Formatted Date-Time editor value

<dxdf:DataFormView x:Name="dataForm" 
                   CommitMode="Input" 
                   IsAutoGenerationEnabled="False">
    <dxdf:DataFormView.DataObject>
        <local:OrderInfo/>
    </dxdf:DataFormView.DataObject>
    <dxdf:DataFormDateItem FieldName="Date" RowOrder="1" DisplayFormat="d" IsLabelVisible="False"/>
    <dxdf:DataFormDateItem FieldName="Date" RowOrder="2" DisplayFormat="Date: {0:m}" IsLabelVisible="False"/>
</dxdf:DataFormView>
public class OrderInfo : INotifyPropertyChanged {
    DateTime date = new DateTime(2020, 2, 1);
    public DateTime Date {
        get { return this.date; }
        set {
            if (value != this.date) {
                this.date = value;
                NotifyPropertyChanged();
            }
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}
See Also