Skip to content

Instantly share code, notes, and snippets.

@haavamoa
Last active July 25, 2020 19:45
Show Gist options
  • Save haavamoa/7b102f925a5e20598c991e781bc5e38b to your computer and use it in GitHub Desktop.
Save haavamoa/7b102f925a5e20598c991e781bc5e38b to your computer and use it in GitHub Desktop.
public class IsEmptyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(!(value is string stringValue)) return false;
return string.IsNullOrEmpty(stringValue);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return !(bool)Convert(value, targetType, parameter, culture);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment