Browse Source

Add converters

pull/5/head
Ionite 1 year ago
parent
commit
3f90385a9a
No known key found for this signature in database
  1. 19
      StabilityMatrix/Converters/NullToVisibilityConverter.cs
  2. 17
      StabilityMatrix/Converters/StringNullOrEmptyToVisibilityConverter.cs

19
StabilityMatrix/Converters/NullToVisibilityConverter.cs

@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace StabilityMatrix.Converters;
public class NullToVisibilityConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object? value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

17
StabilityMatrix/Converters/StringNullOrEmptyToVisibilityConverter.cs

@ -0,0 +1,17 @@
using System;
using System.Windows;
using System.Windows.Data;
namespace StabilityMatrix.Converters;
public class StringNullOrEmptyToVisibilityConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
}
public object? ConvertBack(object? value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
Loading…
Cancel
Save