Search code examples
wpfdata-bindingmultibinding

Syntax error while implement IMultiValueConverter-WPF


I'm newbie on WPF and I would like to implement IMultiValueConverter

On MainWindow.xaml.cs:
public class CanSelectNextPage2 : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (values[0] is bool && values[1] is bool && values[2] is string && values[3] is string && values[4] is string)
            if (((bool)values[0] || (bool)values[1]) &&
                (values[2] != null) && (values[3] != null) && (values[4] != null)
                (values[2].ToString().Length > 1) &&
                (values[3].ToString().Length > 1) &&
                (values[4].ToString().Length > 1))
            {
                return true;
            }

        return false;
    }
    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

I got an syntax error on:

(values[4] != null)

Error is: Method name expected

Can someone please assist?


Solution

  • You are missing the && operator after (values[4] != null).