D
D
DarkByte20152016-05-14 13:55:26
WPF
DarkByte2015, 2016-05-14 13:55:26

Is it possible to specify several converters in one binding?

It is necessary to bind Visibility to a bool variable at the element, for this I made a converter + I need to invert the value (such logic is simply needed), for this I made another converter, but it doesn’t work out to combine them ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Pavlov, 2016-05-14
@DarkByte2015

You don't need to make a second converter, but configure the one to return the desired value - return Visibility.Collapsed when true and Visibility.Visible when false.

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    if ((bool)value)
    {
        return parameter != null ? Visibility.Collapsed : Visibility.Hidden;
    }
    return Visibility.Visible;
}

And if you just need to check several different checks for one element, then use MultiBinding. I wrote about it here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question