title: Binding MVVMCrossCore - TableView NullReference exception
body: <p>Here the code for my ProductGroupTableViewcell, which must load from a NIB file:</p>
  
  <pre><code>//The cell must load from nib file
  public partial class ProductGroupTableViewCell : MvxTableViewCell
      {
          public static readonly UINib Nib = UINib.FromName ("ProductGroupTableViewCell", NSBundle.MainBundle);
          public static readonly NSString Key = new NSString ("ProductGroupTableViewCell");
          public ProductGroupTableViewCell (IntPtr handle) : base (handle)
          {
  
              this.DelayBind(() =&gt; {
                  var set = this.CreateBindingSet&lt;ProductGroupTableViewCell, ProductModel&gt;();
                  set.Bind(imgProduct.Image).To(pm =&gt; pm.ProductImage1).WithConversion("UrltoImageConverter");
                  set.Bind(lblCurrencySymbol).To(pm =&gt; pm.CurrencySymbol);
                  set.Bind(lblProductCost).To(pm =&gt; pm.ProductExchangeCost).WithConversion("ExchangeCostToStringConverter");
                  set.Bind(lblProductName).To(pm =&gt; pm.ProductName);
                  set.Bind(lblProductQuantity).To(pm =&gt; pm.ProductQuantity);//.WithConversion("SpecialSymbolAtConverter");
                  set.Apply();
              });
          }
  
      public static ProductGroupTableViewCell Create () //Don't know when is this called ??
          {
              return (ProductGroupTableViewCell)Nib.Instantiate (null, null) [0];
          }
  
      }
  </code></pre>
  
  <p>TableView source:</p>
  
  <pre><code>public class MvxProductTableViewSource: MvxTableViewSource
      {
          public MvxProductTableViewSource(UITableView tableView) : base(tableView)
          {
              //tableView.RegisterClassForCellReuse(typeof(ProductGroupTableViewCell), ProductGroupTableViewCell.Key);
              tableView.RegisterNibForCellReuse (ProductGroupTableViewCell.Nib, ProductGroupTableViewCell.Key);
          }
  
          protected override UITableViewCell GetOrCreateCellFor(UITableView tableView, NSIndexPath indexPath, object item)
          {
              return tableView.DequeueReusableCell (ProductGroupTableViewCell.Key, indexPath);
          }
      }
  </code></pre>
  
  <p>View Controller; CrossCore so no usage of UITableViewController here: Most import this region <code>#MVVM bindings</code> for table contains my binding of TableViewSource and ViewModel. 
  In <code>HandleTouchUpInside</code> event, I am changing the data context. </p>
  
  <p>First of all, I am not able to view the table data when the view loads. When I do touchup Inside I get the data context properly.</p>
  
  <p>I delayed the binding of Cell but with <code>Set.Apply()</code>, the application crashes throwing a NullReference exception:</p>
  
  <pre><code>public partial class ProductGroupDetailController : UIViewController, IMvxBindable
      {
          private ProductGroupDetailViewModel2 productGrpViewModel = new ProductGroupDetailViewModel2();
          UIScrollView scrollView;
          List&lt;UIButton&gt; buttonlist;
  
          private  String[] categorylist ;
  
          public ProductGroupDetailController () : base ("ProductGroupDetailController", null)
          {
              buttonlist=new List&lt;UIButton&gt;();
              this.CreateBindingContext();
              DataContext = productGrpViewModel.ProductGroup;
          }
  
          #region forBinding
          public IMvxBindingContext BindingContext { get; set; }
  
          protected override void Dispose(bool disposing)
          {
              if (disposing)
              {
                  BindingContext.ClearAllBindings();
              }
  
              base.Dispose(disposing);
          }
  
          public object DataContext
          {
              get { return BindingContext.DataContext; }
              set { BindingContext.DataContext = value; }
          }
          #endregion
  
  
          public override void ViewDidLoad ()
          {
              base.ViewDidLoad ();
  
              #region code for horizontal scroll list
              if (productGrpViewModel != null &amp;&amp; productGrpViewModel.ProductGroup.Count &gt; 0)
                  {
                  categorylist = productGrpViewModel.ProductGroup.Select (p =&gt; p.CategoryName).ToArray();
  
  
                  // Perform any additional setup after loading the view, typically from a nib.
                  float h = 30.0f;
                  float w = 100.0f;
                  float padding = 10.0f;
                  int n = categorylist.Length;
                  View.BackgroundColor=UIColor.FromPatternImage(new UIImage("background.png"));
  
                  scrollView=new UIScrollView {
                      Frame = new RectangleF (0, 126, View.Frame.Width,h + 2 * padding),
                      ContentSize = new SizeF ((w + padding) * n, h),
                      AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                      ShowsHorizontalScrollIndicator = false
                  };
  
                  for (int i=0; i&lt;n; i++) 
                  {
                      var button = UIButton.FromType (UIButtonType.RoundedRect);
                      button.SetTitle (categorylist[i].ToString (), UIControlState.Normal);
                      button.SetTitleColor (UIColor.White, UIControlState.Normal);
                      button.Font = UIFont.FromName ("Helvetica", 18f);
                      button.Frame = new RectangleF (padding * (i + 1) + (i * w),padding, w, h);
                      scrollView.AddSubview (button);
                      buttonlist.Add (button);
                      buttonlist [i].TouchUpInside += HandleTouchUpInside; 
                  }
                  buttonlist [0].BackgroundColor = UIColor.LightGray;
                  View.AddSubview (scrollView);
              #endregion horizontal scroollist
  
  
                  #MVVM bindings for table
                  var source = new MvxProductTableViewSource (ProductTable);
                  ProductTable.Source = source;
  
                  var set = this.CreateBindingSet&lt;ProductGroupDetailController, ProductCategoryModel2&gt;();
                  set.Bind(source).For(s =&gt; s.ItemsSource).To(vm =&gt; vm.Products);
                  set.Apply();
  
                  //source.ReloadTableData ();
              }
          }
  
  
          void HandleTouchUpInside(object sender,EventArgs e)
          {
              //based on category title update the UITableView with new products
              List&lt;ProductCategoryModel2&gt; t = productGrpViewModel.ProductGroup.ToList ();
  
              //set DataContext to new product group
              DataContext = t.FirstOrDefault(catname =&gt; catname.CategoryName == title);
  
              ProductTable.PagingEnabled=true;
              ProductTable.Bounces=true;
              ProductTable.PagingEnabled=true;
              ProductTable.ReloadData ();
          }
  
      }
  }
  </code></pre>
  
  <p>Here the stack trace of the Nullreference exception:</p>
  
  <pre><code>System.NullReferenceException: Object reference not set to an instance of an object
    at Cirrious.MvvmCross.Binding.Bindings.Target.Construction.MvxTargetBindingFactoryRegistry.TryCreateSpecificFactoryBinding (System.Object target, System.String targetName, IMvxTargetBinding&amp; binding) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Bindings.Target.Construction.MvxTargetBindingFactoryRegistry.CreateBinding (System.Object target, System.String targetName) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding..ctor (Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder+&lt;&gt;c__DisplayClass1.&lt;Bind&gt;b__0 (Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00000] in &lt;filename unknown&gt;:0
    at System.Linq.Enumerable+&lt;CreateSelectIterator&gt;c__Iterator10`2[Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription,Cirrious.MvvmCross.Binding.Bindings.IMvxUpdateableBinding].MoveNext () [0x00059] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2269
    at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (IMvxBindingContextOwner view, IEnumerable`1 bindings, System.Object clearKey) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (IMvxBindingContextOwner view, System.Object target, IEnumerable`1 bindingDescriptions, System.Object clearKey) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding (IMvxBindingContextOwner view, System.Object target, Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription bindingDescription, System.Object clearKey) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription`1[MonoTouch.UIKit.UIImage].Apply () [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet`2[OnBoardPOS.IOS.ProductGroupTableViewCell,OnBoardPOS.WP8.Framework.Model.ProductModel].Apply () [0x00000] in &lt;filename unknown&gt;:0
    at OnBoardPOS.IOS.ProductGroupTableViewCell.&lt;ProductGroupTableViewCell&gt;m__1D () [0x001c3] in /Users/admin/Desktop/leelaswork/withouttabs/OnBoardPOS.IOS/views/ProductGroupTableViewCell.cs:28
    at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContext.OnDataContextChange () [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContext.set_DataContext (System.Object value) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Touch.Views.MvxTableViewCell.set_DataContext (System.Object value) [0x00000] in &lt;filename unknown&gt;:0
    at Cirrious.MvvmCross.Binding.Touch.Views.MvxBaseTableViewSource.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00000] in &lt;filename unknown&gt;:0
  </code></pre>