I have created a converter which looks like this:
public class SecondsToHoursMinutesValueConverter
: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var t = TimeSpan.FromSeconds((int)value);
return string.Format("{0:D2} hours {1:D2} minutes", t.Hours, t.Minutes);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Now I want to bind it with:
runtime.SetBinding(Label.TextProperty, new Binding("Runtime"), BindingMode.Default,
new SecondsToHoursMinutesValueConverter(), null);
However, VS does not like it and says there is an error in that code:
Error 1 The type arguments for method 'Xamarin.Forms.BindableObjectExtensions.SetBinding(Xamarin.Forms.BindableObject, Xamarin.Forms.BindableProperty, System.Linq.Expressions.Expression<System.Func<TSource,object>>, Xamarin.Forms.BindingMode, Xamarin.Forms.IValueConverter, string)' cannot be inferred from the usage. Try specifying the type arguments explicitly. \git\Xam.Forms.Mvx\CoolBeans\CoolBeans\Pages\DetailedMoviePage.cs 101 13 CoolBeans