Skip to main content
A newer version of this page is available. .

How to: Format Display Values via Standard Format Specifiers

This example shows how to format numeric and date-time values using standard format specifiers.

Note

The code sample below illustrates how to format numeric and date-time values using standard format specifiers. To use this specifiers in your project, reference a DevExpress.Xpf.Core, DevExpress.Xpf.Layout.Core and DevExpress.Xpf.LayoutControl assemblies.

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="200" Width="348" xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
    <Grid>
        <dxlc:GroupBox Header="Standard Specifiers" Name="groupBox2" Padding="5">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Label Content="Currency:" VerticalAlignment="Center" Margin="0,4"></Label>
                <dxe:SpinEdit Name="spinEdit1" DisplayFormatString="c2" Margin="1,-1,0,1" Grid.Column="1" VerticalAlignment="Center">
                    <dxe:SpinEdit.EditValue>
                        349.99
                    </dxe:SpinEdit.EditValue>
                </dxe:SpinEdit>
                <Label Content="Scientific:" Grid.Row="1" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="0,4,182,4"></Label>
                <dxe:SpinEdit Name="spinEdit2" DisplayFormatString="e1" Margin="1,0,0,0" Grid.Row="1" Grid.Column="1" MaskType="None" VerticalAlignment="Center">
                    <dxe:SpinEdit.EditValue>
                        12345
                    </dxe:SpinEdit.EditValue>
                </dxe:SpinEdit>
                <Label Content="Short Date:" Grid.Row="2" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="0,4,182,4"></Label>
                <dxe:DateEdit Name="dateEdit1" DisplayFormatString="d" Grid.Row="2" Grid.Column="1"
                            Margin="1,0,1,2" EditValue="10.10.2010" VerticalAlignment="Center"></dxe:DateEdit>
                <Label Content="Full Date-Time:" Grid.Row="3" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="0,4,182,4"></Label>
                <dxe:DateEdit Name="dateEdit2" DisplayFormatString="F" Grid.Row="3" Margin="1,0,2,6" Grid.Column="1" DataContext="{Binding}" Mask="dd, MMMM, yyyy hh:mm tt" EditValue="10 September 2010 10:00 AM" VerticalAlignment="Center"></dxe:DateEdit>
            </Grid>
        </dxlc:GroupBox>
    </Grid>
</Window>