StringToBooleanConverter.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.ComponentModel;
  3. using System.Globalization;
  4. using Xamarin.Forms;
  5. namespace InABox.Mobile
  6. {
  7. public class StringToBooleanConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. return !String.IsNullOrWhiteSpace(value as String);
  12. }
  13. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. throw new NotImplementedException();
  16. }
  17. }
  18. public class StringWithDefaultValueConverter : IValueConverter
  19. {
  20. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  21. {
  22. return String.IsNullOrWhiteSpace(value as String)
  23. ? parameter
  24. : value;
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. }
  31. }