在数据网格中显示日期时,有没有办法强制Silverlight使用用户区域设置?
JD。
答案 0 :(得分:4)
您可以使用查看System.Globalization.CultureInfo.CurrentCulture
public class SmartDateConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
DateTime date;
culture = System.Globalization.CultureInfo.CurrentCulture;
if (value != null && DateTime.TryParse(value.ToString(), out date))
{
string strDate = string.Empty;
strDate = date.ToString(culture.DateTimeFormat.ShortDatePattern.ToString());
return strDate;
}
return null;
}
答案 1 :(得分:0)
请参阅此StackOverflow问题的答案: How to change date format in Silverlight DatePicker control?