I'm developing an app with MvvmCross which uses storyboards for the UI. Rather than using XIB files for table cells, I'm trying to create the cells from within the storyboard. The storyboard generates the class for the cell fine then inside that class I bind to my model. The cells are being created but the following error occurs upon binding to each label within the cell, where 'MyStringProperty' is the name of the property I'm trying to bind to (either Name, PhoneNumber or Email):
Failed to create target binding for binding Text MyStringProperty
The table is being created the same way as in Stuart's Kitten Cell tutorial, except instead of a XIB I'm using the following line of code to signify using the generated class for the cell:
tableView.RegisterClassForCellReuse(typeof(MyCell), MyCell.Key);
The binding of the data in the cell is also being done the same way as in Stuart's Kitten Cell tutorial.
Here is the code for MyCell
public partial class MyCell : MvxTableViewCell
{
public static readonly NSString Key = new NSString("MyCell");
public MyCell(IntPtr handle) : base(handle)
{
this.DelayBind(() =>
{
var set = this.CreateBindingSet<MyCell, ContactModel>();
set.Bind(myLabelOne).To(contact => contact.Name);
set.Bind(myLabelTwo).To(contact => contact.PhoneNumber);
set.Bind(myLabelThree).To(contact => contact.Email);
set.Apply();
});
}
}
The designer:
[Register ("MyCell")]
partial class MyCell
{
[Outlet]
MonoTouch.UIKit.UILabel myLabelOne{ get; set; }
[Outlet]
MonoTouch.UIKit.UILabel myLabelTwo{ get; set; }
[Outlet]
MonoTouch.UIKit.UILabel myLabelThree{ get; set; }
void ReleaseDesignerOutlets ()
{
if (myLabelOne!= null) {
myLabelOne.Dispose ();
myLabelOne= null;
}
if (myLabelTwo!= null) {
myLabelTwo.Dispose ();
myLabelTwo= null;
}
if (myLabelThree!= null) {
myLabelThree.Dispose ();
myLabelThree= null;
}
}
}