FormatConverter.cs 673 B

12345678910111213141516171819202122232425
  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. var fmt = String.IsNullOrWhiteSpace(Format)
  12. ? "{0}"
  13. : $"{{0:{Format}}}";
  14. return String.Format($"{fmt}", value);
  15. }
  16. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  17. {
  18. throw new NotImplementedException();
  19. }
  20. }
  21. }