Is there a way to force Silverlight to use the users locale settings when presenting dates in a datagrid?
JD.
Is there a way to force Silverlight to use the users locale settings when presenting dates in a datagrid?
JD.
You could use a converter which looks at the 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;
}