Showing posts with label datepicker. Show all posts
Showing posts with label datepicker. Show all posts

Thursday, March 25, 2010

Customise DatePicker format

In Silverlight DatePicker control the SelectedDateFormat allows only two values i.e long and short.

When I set it to short the date value in the DatePicker text box is displayed as mm/dd/yyyy.

To display date as dd-mmm-yyyy (or any other format), we need to change the local culture

   public App()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

or change the format of the local culture.

        public App()
{
Thread.CurrentThread.CurrentCulture = (CultureInfo) Thread.CurrentThread.CurrentCulture.Clone();
Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "D/m/yyyy";