DXCollectionView.DisplayFormat Property
Gets or sets the pattern used to format list items. This is a bindable property.
Namespace: DevExpress.Maui.CollectionView
Assembly: DevExpress.Maui.CollectionView.dll
NuGet Package: DevExpress.Maui.CollectionView
Declaration
public string DisplayFormat { get; set; }
Property Value
Type | Description |
---|---|
String | The pattern used to format the CollectionView’s items. |
Remarks
Use the DisplayFormat
property to format the CollectionView item’s display value and add additional text. The pattern should have the following structure:
<custom static text>{0:<format specifier<precision specifier>>}<custom static text>
- {0} – The CollectionView item value’s placeholder. The CollectionView obtains item values from DisplayMember.
- format specifier – The format type (currency, scientific, and so on).
- precision specifier – The number of characters displayed after the decimal point.
For example, set the DisplayFormat
property to Price: {0:c2}
to display currency values. If the summary value is 123, its formatted equivalent is Price: $123.00.
Refer to the following pages for more information about format specifiers:
- Standard Numeric Format Strings
- Custom Numeric Format Strings
- Standard Date and Time Format Strings
- Custom Date and Time Format Strings
The following example formats a CollectionView’s items:
<dxcv:DXCollectionView ItemsSource="{Binding Data}"
DisplayMember="Name"
DisplayFormat="Contact: {0}">
</dxcv:DXCollectionView>
In XAML, insert empty brackets into the beginning of a format string if it starts with a placeholder. Refer to the following page for more information: {} Escape sequence / markup extension.
You can also define the DXCollectionView.ItemTemplate property to format and customize the CollectionView item’s content.