Created
July 25, 2020 19:39
-
-
Save haavamoa/26020fbac2f322d41ff9a762c3644272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IsEmptyConverter : IValueConverter, IMarkupExtension | |
{ | |
public bool Inverted { get; set; } | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
if(!(value is string stringValue)) return false; | |
return Inverted ? !string.IsNullOrEmpty(stringValue) : string.IsNullOrEmpty(stringValue); | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
return !(bool)Convert(value, targetType, parameter, culture); | |
} | |
public object ProvideValue(IServiceProvider serviceProvider) | |
{ | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment