I am using converter in windows store app in twoway mode.
public object ConvertBack(object value, Type targetType,
object parameter, string language)
{
return ((DateTime)value).ToString("yyyy-MM-dd");
}
Another approach:
public object ConvertBack(object value, Type targetType,
object parameter, string language)
{
DateTime dt;
DateTime.TryParseExact(value.ToString(),
"yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None,
out dt);
return dt;
}
Can anyone tell me why this does not work for me? And afkors, how to solve it?
From datePicker converter gets this string: 19.1.2014 15:43:02 +01:00 and is unable to conver.
Error message: Converter failed to convert value of type 'System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' to type 'DateTime'; BindingExpression: Path='DateFrom' DataItem='Infomed21_Mbx.Data.resultFilter, Infomed21-Mbx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Windows.UI.Xaml.Controls.DatePicker' (Name='datePicker_from'); target property is 'Date' (type 'DateTime')