Skip to main content

Microsoft Silverlight

Unanswered Question Datepicker ignores cultureRSS Feed

(0)

Lexxy
Lexxy

Member

Member

0 points

4 Posts

Datepicker ignores culture

 Hello,

I have a Silverlight Datepicker which accepts input in the format DD/MM/YYYY (en-GB). This works normally. However, when a user inputs a short date, DD/MM, the control apparently ignores its culture and converts the value to MM/DD.

I was wondering if there was a solution to this problem without having to manually fix the Datepicker source code.

Cheers.

 

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17241 points

1,466 Posts

Re: Datepicker ignores culture

Hi,

Lexxy:
I have a Silverlight Datepicker which accepts input in the format DD/MM/YYYY (en-GB). This works normally. However, when a user inputs a short date, DD/MM, the control apparently ignores its culture and converts the value to MM/DD.

How did you formate your date format?

We did have a test in our labs, but did not reproduce your problem.

We format the datetime in the silveright's app.xaml.cs file, like below:

 private void Application_Startup(object sender, StartupEventArgs e)
        {

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
                this.RootVisual = new MainPage();
            }
        }

It works fine, it doese not convert the value into MM/DD, when your input DD/MM.

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Lexxy
Lexxy

Member

Member

0 points

4 Posts

Re: Datepicker ignores culture

Hello Amanda,

Thank you for your advice. Unfortunately adding the lines:

Amanda Wang - MSFT:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";

To my application startup did not fix this issue. I also tried setting CurrentUICulture.

The datepicker watermark when there is no text entered is:

<dd/MM/yyyy>

If I enter: 01/05/2009 the picker output is 01/05/2009. Correct.

If I enter 01/22/2009 the picker rejects my input, and resets to last value. Correct.

If I enter 22/05/2009 the picker output is 22/05/2009. Correct.

If i enter: 01/05 the picker output is 05/01/2009. Wrong.

If i enter 22/01 the picker rejects my input, and resets to last value. Wrong.

This problem makes this control totally unsuitable for my LOB application. Any further ideas why this might be happening?

 ---

System.Windows.Controls v2.0.50727

System.Windows.Controls.Input.Toolkit v2.0.50727

---

Oh, I should also mention I tested the control on the Silverlight Codeplex Toolkit site. It suffers from the same problem.

-Lexxy.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities