ctor System.NullReferenceException: Object reference not set to an instance of an object

Hi,
I'm using the framework mvvmcross with a RecyclerView customed.
I have an instance of AnimalEditText in the DelayBind I would like to know if this is correct because randomly the bindableAnimal object in my class CatEditText is coming null in spit of AnimalItemInput is initialized first. This is the stacktrace:

MyProject.CatEditText..ctor (Android.Content.Context context, MyProject.BindableAnimal bindableAnimal)
<.ctor>b__0 ()
MvxBindingContext.OnDataContextChange ()
MvxBindingContext.set_DataContext (System.Object value)
MvxRecyclerViewHolder.set_DataContext (System.Object value)
MvxRecyclerAdapter.OnBindViewHolder (Android.Support.V7.Widget.RecyclerView+ViewHolder holder, System.Int32 position)
AnimalsRecyclerViewAdapter.OnBindViewHolder (Android.Support.V7.Widget.RecyclerView+ViewHolder holder, System.Int32 position)
RecyclerView+Adapter.n_OnBindViewHolder_Landroid_support_v7_widget_RecyclerView_ViewHolder_I (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_holder, System.Int32 position)

public abstract class AnimalItemInput : LinearLayoutCompat
    {
        public IMvxBindingContext BindingContext { get; set; }
        public BindableAnimal BindableAnimal { get; set; }
        protected abstract AnimalEditText CatEditText { get; set; }

        protected AnimalItemInput(Context context, IMvxAndroidBindingContext bindingContext) : base(context)
        {
                BindingContext = bindingContext;
                Orientation = Vertical;
                this.DelayBind(BindAnimals);
        }

        private void BindAnimals()
        {
                var set = this.CreateBindingSet<AnimalItemInput, BindableAnimalViewModel>();
                set.Bind(this)
                    .For(v => v.BindableAnimal)
                    .To(vm => vm.BindableAnimal)
                    .OneWay();
                set.Apply();
        }
    }



public class CatItemInput : AnimalItemInput
    {
        protected sealed override AnimalEditText AnimalEditText { get; set; }

        public CatItemInput(Context context, IMvxAndroidBindingContext bindingContext)
                : base(context, bindingContext)
        {
                this.DelayBind(() =>
                {
                    AnimalEditText = new CatEditText(context, BindableAnimal);
                    InitializeView();
                    CreateBindings();
                });
        }
    }

public class CatEditText : AnimalEditText
    {
        public CatEditText(Context context, BindableAnimal bindableAnimal)
                : base(context, bindableAnimal)
        {
            KeyListener = DigitsKeyListener.GetInstance(BindableAnimal.Things);
        }
    }
Sign In or Register to comment.