Formatting in WPF DatePicker (SfDatePicker)

The SfDatePicker control allows the user to format the display text in various ways.

Using the FormatString

The FormatString property determines the format specifier by which the display text has to be formatted.

The following code sample shows how to create a date picker with a month day pattern:

  • xaml
  • <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
                <syncfusion:SfDatePicker VerticalAlignment="Center" 
                                       Width="200" Margin="15"

    Format string

    Specifying format for the DateSelector

    The SelectorFormatString property used to specify format for the DateSelector

  • xaml
  • <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <syncfusion:SfDatePicker SelectorFormatString="M"   x:Name="sfdatePicker" VerticalAlignment="Center"  Width="200" Margin="15" />

    Selector format string


    A detailed explanation of standard date time formatting is available here. The result string produced by these format specifiers are influenced by the settings in the Regional Options control panel. Computers with different cultures or different date and time settings will generate different result strings.