Skip to main content

DataFormTextItemWithAffixBase.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 Description
String

The text pattern for the editor’s value.

Remarks

Use the DisplayFormat property to format the editor value and add additional text. The pattern has the following structure:

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

  • {0} – The editor value’s placeholder.
  • format specifier – The format type (currency, scientific, and so on).
  • precision specifier – The number of characters displayed after the decimal point.

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

If you do not need to display extra text with the formatted numeric value, you can put a numeric format specifier only in the format string (for instance, “f2”).

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

Example

The following example shows how to format the display value for a Data Form’s numeric editor:

DevExpress MAUI DataForm - Formatted numeric value

<dxdf:DataFormView x:Name="dataForm" 
                   CommitMode="Input" 
                   IsAutoGenerationEnabled="False">
    <dxdf:DataFormView.DataObject>
        <local:DataInfo/>
    </dxdf:DataFormView.DataObject>
    <dxdf:DataFormNumericItem FieldName="NumericValue" 
                              EditorWidth="300"               
                              RowOrder="0" 
                              IsLabelVisible="False"
                              ClearIconVisibility="Always" 
                              ReturnType="Next"
                              AllowLooping="False"
                              AllowNullValue="True"
                              IsUpDownIconVisible="True"
                              MinValue="1"
                              MaxValue="100"
                              StepValue="0.1"
                              DisplayFormat="Value: {0:f2}"/>
</dxdf:DataFormView>
public class DataInfo : INotifyPropertyChanged {
    double numValue;
    public double NumericValue {
        get { return this.numValue; }
        set {
            if (value != this.numValue) {
                this.numValue = value;
                NotifyPropertyChanged();
            }
        }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}
See Also