This works great:
<my:DatePicker IsTodayHighlighted="True" Width="200">
</my:DatePicker>
But I want to format the date, something like this:
<my:DatePicker IsTodayHighlighted="True" Width="200" Format="yyyy-mm-dd">
</my:DatePicker>
Anyone know the syntax for this?
Unfortunately the DatePicker control currently does not support free DateTime formats.
If this is something you're interested in seeing up support in future version of DatePicker, please create a codeplex feature request that suggests that. http://silverlight.codeplex.com/WorkItem/Create.aspx
Just to point out that the new Silverlight Toolkit March 2009 TimePicker & TimeUpDown controls do support a full range of globalization options. One of those include free DateTime formats. So it is just a matter of public interest on whether or not we port that ability back to DatePicker. Have a look at the format for TimePicker @ http://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201#TimePicker
In the meanwhile, The best workaround is to either change the local culture or the format on the local culture.
public App()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL");
or change the format on the local culture.
public App()
{
Thread.CurrentThread.CurrentCulture = (CultureInfo) Thread.CurrentThread.CurrentCulture.Clone();
Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "D/m/yyyy";
You should define a custom control template and edit the textbox of the datepicker control to format the text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With