123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.ComponentModel;
- using System.Globalization;
- using Xamarin.Forms;
- namespace InABox.Mobile
- {
- public class StringToBooleanConverter : UtilityConverter<String,bool>
- {
- public bool HasValue { get; set; }
- protected override bool Convert(string value)
- {
- var empty = String.IsNullOrWhiteSpace(value);
- return HasValue
- ? !empty
- : empty;
- }
- public StringToBooleanConverter()
- {
- HasValue = true;
- }
-
- }
-
- public class StringWithDefaultValueConverter : IValueConverter
- {
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return String.IsNullOrWhiteSpace(value as String)
- ? parameter
- : value;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|