using System; using System.Globalization; using System.Windows.Data; namespace DaSaSo.Wpf.Converters { [ValueConversion(typeof(DateTime), typeof(String))] public class StringToDateTimeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { DateTime val = (DateTime)value; return string.Format("{0}.{1}.{2} {3}:{4}",val.Day,val.Month, val.Year, val.Hour, val.Minute); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { DateTime result; if (DateTime.TryParse((value as string), out result)) { return result; } else { throw new Exception(); } } } }