1
votes

I have a button that is bind to an mvxCommand. After the binding the button is disabled. Before the binding he is enabled.

Anyone who can tell me why this happened?

My View:

public override void ViewDidLoad()
        {
            Debug.WriteLine("VatButton6 = " + VatButton6.Enabled); // this is true
            var set = this.CreateBindingSet<CreatePaymentView, CreatePaymentViewModel>();
            set.Bind(AmountTxt).To(vm => vm.Amount);
            set.Bind(ReferenceTxt).To(vm => vm.Reference);
            set.Bind(VatButton6).To(vm => vm.RegisterVatCommand); //CommandParameter("21%");
            set.Apply();

            Debug.WriteLine("VatButton = " + VatButton6.Enabled); // this is false;
        }

My Command:

public IMvxCommand RegisterVatCommand
    {
        get { return new MvxCommand(RegisterVat); }
    }

    public void RegisterVat()
    {
    //    switch (vat) 
    //    {
    //        case "21%":
    //            Vat = 21;
    //            break;
    //        case "6%":
    //           Vat = 6;
    //            break;
    //        case "0%":
    //            Vat = 0;
    //            break;
    //        case "nvt":
    //            Vat = -1;
    //            break;
    //        default:
    //            throw new ArgumentException("invalid button title");
    //    }
    }
2

2 Answers

0
votes

I can't comment yet, but can you try and remove the other two bindings

    set.Bind(AmountTxt).To(vm => vm.Amount);
    set.Bind(ReferenceTxt).To(vm => vm.Reference);

And then test if it works?

I copied your code and it works fine for me, so there is nothing wrong with it.

0
votes

Try adding the commands in Constructor