public override void ViewDidLoad() { base.ViewDidLoad(); //Show an edit button //NavigationItem.RightBarButtonItem = EditButtonItem; this.Title = "Sample"; if (tableView != null) { dataSource = new DataBoundUITableViewSource<CustomCell, DataItem>(tableView); dataSource.RowAnimation = UITableViewRowAnimation.None; dataSource.RowSelect += HandleDataSourceRowSelect; dataSource.RowDeselect += HandleDataSourceRowDeselect; int count = 500; for (int i=0; i<count; i++) { DataItem item = new DataItem(); int rand = random.Next(28, 144); for (int c=1; c<rand; c++) { item.Text += "Test " + c.ToString() + " "; } item.Height = CustomCell.GetCellHeight(item); dataSource.List.Add(item); } tableView.Source = dataSource; } }
public static float GetCellHeight(DataItem item) { SizeF size = GetStringSize(item.Text, font, new SizeF(320.0f, 1000.0f), UILineBreakMode.WordWrap); return size.Height; }
void HandleDataSourceRowSelect(object sender, DataItem item) { Console.WriteLine(item.Height); }