TimeSpanToStringConverter.cs 628 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Globalization;
  3. using Xamarin.Forms;
  4. namespace InABox.Mobile
  5. {
  6. public class FormatConverter : IValueConverter
  7. {
  8. public String Format { get; set; }
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. return String.IsNullOrWhiteSpace(Format)
  12. ? value
  13. : String.Format($"{{0:{Format}}}", value);
  14. }
  15. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  16. {
  17. throw new NotImplementedException();
  18. }
  19. }
  20. }