forked from xamarin/ios-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataSource.cs
42 lines (33 loc) · 967 Bytes
/
DataSource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using Foundation;
using UIKit;
namespace MonoDevelopTouchCells {
public class DataSource : UITableViewDataSource {
List<Item> Data { get; set; }
public DataSource (IEnumerable<Item> data)
{
this.Data = new List<Item> (data);
}
public override nint RowsInSection (UITableView tableView, nint section)
{
return this.Data.Count;
}
public override nint NumberOfSections (UITableView tableView)
{
return 1;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
string customCellID = "MyCellID" + indexPath.Section + indexPath.Row;
CustomCell cell = (CustomCell) tableView.DequeueReusableCell (customCellID);
if (cell == null) {
cell = new CustomCell (UITableViewCellStyle.Default, customCellID);
Item item = this.Data [indexPath.Row];
cell.Title = item.Title;
cell.Checked = item.Checked;
}
return cell;
}
}
}