MvvmCross: Cannot convert lambda expression to type 'string' because it is not a delegate type

1.4k Views Asked by At

I get this error in my binding:

Cannot convert lambda expression to type 'string' because it is not a delegate type

This ahppen on this line of code:

bindings.Bind(userNameTextView).For(x => x.Layer.BorderColor).To(x => x.LoginError).OneWay();".

Here is my code

using System;
using System.Drawing;
using Foundation;
using UIKit;
using CoreGraphics;
using Cirrious.MvvmCross.Touch.Views;
using MvvmCross_POC.Shared.ViewModels;
using Cirrious.MvvmCross.Binding.BindingContext;
using MvvmCross_POC.iOS.Converters;
using System.Linq;

namespace MvvmCross_POC.iOS.Views
{
    public partial class LoginViewController : MvxViewController
    {
        private UITextView userNameTextView;
        private UITextView passwordTextView;
        private UIButton loginButton;

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Title = "login";

            this.View.BackgroundColor = UIColor.White;

            var loginView = new UIView(){
                Frame = new RectangleF((float)this.View.Bounds.Width / 4, (float)this.View.Bounds.Height / 4, (float)this.View.Bounds.Width / 2, (float)this.View.Bounds.Height / 2)
            };

            userNameTextView = new UITextView()
            {
                Frame = new RectangleF(0, 0, (float)loginView.Bounds.Width, 30),
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth
            };
            userNameTextView.Layer.BorderColor = UIColor.LightGray.CGColor;
            userNameTextView.Layer.BorderWidth = 1;
            userNameTextView.Layer.CornerRadius = 5;

            passwordTextView = new UITextView()
            {
                Frame = new RectangleF(0, 50, (float)loginView.Bounds.Width, 30),
                SecureTextEntry = true,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth
            };
            passwordTextView.Layer.BorderColor = UIColor.LightGray.CGColor;
            passwordTextView.Layer.BorderWidth = 1;
            passwordTextView.Layer.CornerRadius = 5;

            loginButton = new UIButton() {
                Frame = new RectangleF((float)(loginView.Bounds.Width / 2) - 50, 100, 100, 30)
            };
            loginButton.SetTitle("Login", UIControlState.Normal);

            loginView.AddSubviews(userNameTextView, passwordTextView, loginButton);

            this.View.AddSubview(loginView);

            var bindings = this.CreateBindingSet<LoginViewController, LoginViewModel>();
            bindings.Bind(userNameTextView).For(x => x.Text).To(x => x.UserName);
            bindings.Bind(userNameTextView).For(x => x.Layer.BorderColor).To(x => x.LoginError).WithConversion(new BooleanToCGColorConverter());
            bindings.Bind(passwordTextView).For(x => x.Text).To(x => x.Password);
            bindings.Bind(loginButton).For("TouchUpInside").To(x => x.LoginCommand);
            bindings.Apply();
        }
    }
}
0

There are 0 best solutions below