At.FF.Krems.Utils.WPF.Converters.PrioFirstValueMulti.Convert C# (CSharp) Method

Convert() public method

Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
The target must be a boolean
public Convert ( object values, Type targetType, object parameter, CultureInfo culture ) : object
values object The array of values that the source bindings in the produces. The value indicates that the source binding has no value to provide for conversion.
targetType System.Type The type of the binding target property.
parameter object The converter parameter to use.
culture System.Globalization.CultureInfo The culture to use in the converter.
return object
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(bool))
            {
                throw new InvalidOperationException("The target must be a boolean");
            }

            if ((int)values[0] == 0)
            {
                return false;
            }

            if (values[1] == DependencyProperty.UnsetValue)
            {
                return true;
            }

            return !(bool)values[1];
        }
PrioFirstValueMulti