namespace Connected; /// /// A ready made DateTime? to string binding converter with configurable date format and culture /// public class NullableDateConverter : ToStringConverter { public string DateFormat { get; set; } public NullableDateConverter(string format = "yyyy-MM-dd") => DateFormat = format; protected override string? ConvertValue(DateTime? value) => value?.ToString(DateFormat, Culture); protected override DateTime? ConvertValueBack(string? value) => DateTime.ParseExact(value, DateFormat, Culture); } /// /// A ready made DateTime to string binding converter with configurable date format and culture /// public class DateConverter : ToStringConverter { public string DateFormat { get; set; } public DateConverter(string format = "yyyy-MM-dd") => DateFormat = format; protected override string? ConvertValue(DateTime value) => value.ToString(DateFormat, Culture); protected override DateTime ConvertValueBack(string? value) => DateTime.ParseExact(value, DateFormat, Culture); }