using System; using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; using System.Collections.Generic; namespace DerbyNames_MonoTouch { public partial class VixensController : UIViewController { public VixensController () : base ("VixensController", null) { Title = NSBundle.MainBundle.LocalizedString ("Vixens", "Vixens"); } public override void ViewDidLoad () { base.ViewDidLoad (); UITableView tableView; string teamName = "Lansing Derby Vixens"; List fullRosterData = Network.GetRoster(teamName); List data = new List(); fullRosterData.ForEach(derbyName => data.Add(derbyName.Name)); tableView = new UITableView(); tableView.DataSource = new TableViewDataSource(data); tableView.Frame = new RectangleF (0, 0, this.View.Frame.Width,this.View.Frame.Height); this.View.AddSubview(tableView); } public override void ViewDidUnload () { base.ViewDidUnload (); ReleaseDesignerOutlets (); } private class TableViewDataSource : UITableViewDataSource { static NSString kCellIdentifier = new NSString ("DerbyName"); private List list; public TableViewDataSource (List list) { this.list = list; } public override int RowsInSection (UITableView tableview, int section) { return list.Count; } public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell (kCellIdentifier); if (cell == null) { cell = new UITableViewCell ( UITableViewCellStyle.Default, kCellIdentifier); } cell.TextLabel.Text = list[indexPath.Row]; return cell; } } } }