I'm trying to bind a list of objects to a very simple table cell in iOS using Xamarin and MvvmCross and I can't get anything to display.
If I use MvxStandardTableViewSource I can see the items in the list no problem so the issue would not appear to be with the data.
I followed the instructions shown in N+1 6.5 and nothing appeared in my list. I deleted the table cell, followed the instructions again and this time only put one label in the cell and used the default cell height. Still nothing.
Here is my view code:
var tableView = new UITableView(new RectangleF(0, 50, 320, 500), UITableViewStyle.Plain);
Add(tableView);
var source = new MvxSimpleTableViewSource(tableView, JobListCell.Key, JobListCell.Key);
tableView.Source = source;
var set = this.CreateBindingSet<JobListView, JobListViewModel>();
set.Bind(source).To(vm => vm.Jobs);
set.Apply();
tableView.ReloadData();
Here is the JobListCell code:
public partial class JobListCell : MvxTableViewCell
{
public static readonly UINib Nib = UINib.FromName ("JobListCell", NSBundle.MainBundle);
public static readonly NSString Key = new NSString ("JobListCell");
public JobListCell (IntPtr handle) : base (handle)
{
this.DelayBind(() => {
var set = this.CreateBindingSet<JobListCell, JobListItem>();
set.Bind(JobDescriptionLabel).To(item => item.JobDescription);
set.Apply();
});
}
public static JobListCell Create ()
{
return (JobListCell)Nib.Instantiate (null, null) [0];
}
}
Here is the cell designer code so you can see the outlet generated:
[Register ("JobListCell")]
partial class JobListCell
{
[Outlet]
MonoTouch.UIKit.UILabel JobDescriptionLabel { get; set; }
void ReleaseDesignerOutlets ()
{
if (JobDescriptionLabel != null) {
JobDescriptionLabel.Dispose ();
JobDescriptionLabel = null;
}
}
}
Here is the class I'm binding to:
public class JobListItem
{
public int JobId { get; set; }
public string JobDescription { get; set; }
public string JobAddress { get; set; }
public string JobPriority { get; set; }
public override string ToString()
{
return JobDescription;
}
}
Any ideas?