RadDatePicker - Need to Format Date

6 posts, 1 answers
  1. Top Gun
    Top Gun avatar
    20 posts
    Member since:
    Nov 2009

    Posted 08 Jun 2011 Link to this post

    When the user selects a date in the RadDatePicker, I need the date to be displayed as dd/MM/yyyy.  How can I get this format, dd/MM/yyyy, to be displayed in the control?

    my xaml

    <telerik:RadDatePicker Name="myDatePicker" InputMode="DatePicker" Height="30" HorizontalAlignment="Stretch" />
  2. Answer
    Dani
    Admin
    Dani avatar
    848 posts

    Posted 09 Jun 2011 Link to this post

    Hello Amrit,

    Please, check this online help article on the topic of formatting in the RadDateTimePicker control(RadDateTimePicker with InputMode="DatePicker" is the same as RadDatePicker). It describes how you can specify custom formatting. I hope it helps.

    Greetings,
    Dani
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Top Gun
    Top Gun avatar
    20 posts
    Member since:
    Nov 2009

    Posted 09 Jun 2011 Link to this post

    Thanks.  I appreciate the help.
  5. David
    David avatar
    18 posts
    Member since:
    Jan 2011

    Posted 19 Nov 2012 Link to this post

    Hi,

    I don't use code-behind (we use MVVM) - how can I do this in XAML?

    Thanks
  6. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 22 Nov 2012 Link to this post

    Hi Rodney,

    Currently there is no way to set the format in XAML. You can only set this as shown in the link below. In MVVM scenario you can try to achieve this by binding the Culture property of the DateTimePicker to your ViewModel. As this is not very convenient we have logged this in our PITS, you can follow the items progress and vote for it here.

    Regards,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. David
    David avatar
    18 posts
    Member since:
    Jan 2011

    Posted 24 Feb 2013 Link to this post

    Thanks, I went this route:

    public CultureInfo CultureWithFormattedPeriod
    {
        //Hack to get around the fact that there is no custom date format in the Telerik DatePicker
        get
        {
            var tempCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
            tempCultureInfo.DateTimeFormat.ShortDatePattern = "MMyyyy";
     
            return tempCultureInfo;
        }
    }

    and in my View:
    <telerik:RadDateTimePicker
        Culture="{Binding Path=CultureWithFormattedPeriod}"
        InputMode="DatePicker"
        DateSelectionMode="Month"
        SelectedValue="{Binding Path=ExtendedEditor.From, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" />
Back to Top
DevCraft banner