如何更改Silverlight DatePicker控件中的日期格式? [英] How to change date format in Silverlight DatePicker control?
问题描述
这样做很棒:
<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?
推荐答案
不幸的是,DatePicker控件目前不支持免费的DateTime格式。
Unfortunately the DatePicker control currently does not support free DateTime formats.
如果这是您有兴趣看到支持在将来版本的DatePicker中,请创建一个代码段功能请求。
http://silverlight.codeplex.com/WorkItem/Create.aspx
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
只是指出,新的Silverlight Toolkit 2009年3月TimePicker& TimeUpDown控件确实支持全方位的全球化选项。其中之一包括免费的DateTime格式。那么我们是否把这个能力转移回DatePicker,这只是一个公共利益的问题。
查看TimePicker @
http://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201#TimePicker
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";
这篇关于如何更改Silverlight DatePicker控件中的日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!