Xamarin iOS - MVVMCross : Unable to connect button in custom cell with command in ViewModel

ASyedASyed USMember ✭✭

I am using MVVMCross, for my Xamarin iOS project. I am using a button inside the cell. I want to connect it to viewModel through command, but for some reason, I am not able to successfully bind them.

Can someone please have a look and let me know where I am doing wrong or what updates should I make to my code.


public partial class MyCell : MvxCollectionViewCell { public PostImageCell(IntPtr handle) : base(handle) { this.DelayBind(() => { var bSet = this.CreateBindingSet<MyCell, SomeViewModel>(); bSet.Bind(Btn).To(vm => vm.EditPhotoCommand); bSet.Apply(); }); } }


public class SomeViewModel : BaseCoreViewModel { public SomeViewModel() { editPhotoCommand = new BaseMvxCommand(DoShow); } public ICommand EditPhotoCommand { get { return editPhotoCommand; } } private void DoShow() { //} }

I kept some breakpoints and realized that when the MyCell constructor is being called, the code inside this.DelayBind() is not being hit, so i tried removing this.DelayBind but still no use. Whenever I click on the button inside the cell, its not binding to the command inside ViewModel


  • c.lamontc.lamont USUniversity ✭✭
    edited January 2017

    Only difference in code I can see between yours and mine is that my cell constructor is protected instead of public.

    Can you try that, or post some more information.

    I presume you have just written some example of your problem, but your class is MyCell and your constructor is PostImageCell.

Sign In or Register to comment.