Converter Inheritance and Members
Posted: 25 Apr 2018, 12:43
I've been trying to come up with a working solution for piping converters, I've been through everything and decided to just fall back to a generic approach for specific converters.
And the inherited type
This was my final stop on actually getting a converter to behave as I needed it to and I'm getting "Unknown Member" errors thrown at me for the True/False properties.
If inheritance doesn't work, Is there some accepted way to pipe converters in NoesisGUI?
Code: Select all
public class BooleanConverter<T> : IValueConverter
{
public BooleanConverter(T trueValue, T falseValue)
{
True = trueValue;
False = falseValue;
}
public T True { get; set; }
public T False { get; set; }
public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is bool && ((bool)value) ? True : False;
}
public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is T && EqualityComparer<T>.Default.Equals((T)value, True);
}
}Code: Select all
public class BooleanToVisibilityConverter : BooleanConverter<Visibility>
{
public BooleanToVisibilityConverter() :
base(Visibility.Visible, Visibility.Collapsed)
{ }
}If inheritance doesn't work, Is there some accepted way to pipe converters in NoesisGUI?