void useTableView()
        {
            if (this.View.Subviews.Length > 0)
            {
                this.View.Subviews [0].RemoveFromSuperview();
            }

            // optional
            this.dataSource.Settings.TableView.CreateCell((UITableView tableView, NSIndexPath indexPath, NSObject item) => {
                UITableViewCell cell = tableView.DequeueReusableCell("cell");
                if (cell == null)
                {
                    cell = new UITableViewCell(UITableViewCellStyle.Value1, "cell");
                }
                return(cell);
            });

            // optional
            this.dataSource.Settings.TableView.InitCell((UITableView tableView, NSIndexPath indexPath, UITableViewCell cell, NSObject item) => {
                DSItem dsitem             = (DSItem)item;
                cell.TextLabel.Text       = dsitem.Name;
                cell.DetailTextLabel.Text = string.Format("{0}", dsitem.Value);
            });

            UITableView table = new UITableView(this.View.Bounds);

            table.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            table.DataSource       = this.dataSource;
            this.View.AddSubview(table);
        }
        void useCollectionView()
        {
            if (this.View.Subviews.Length > 0)
            {
                this.View.Subviews [0].RemoveFromSuperview();
            }

            this.dataSource.Settings.CollectionView.CreateCell((UICollectionView collectionView, NSIndexPath indexPath, NSObject item) => {
                return((UICollectionViewCell)collectionView.DequeueReusableCell("cell", indexPath));
            });

            this.dataSource.Settings.CollectionView.InitCell((UICollectionView collectionView, NSIndexPath indexPath, UICollectionViewCell cell, NSObject item) => {
                DSCollectionViewCell dscell = (DSCollectionViewCell)cell;
                DSItem dsitem          = (DSItem)item;
                dscell.Label.Text      = this.dataSource.TextFromItem(item, null);
                dscell.ImageView.Image = dsitem.Image;
            });

            UICollectionViewFlowLayout layout = new UICollectionViewFlowLayout();

            layout.ItemSize = new CGSize(140, 140);

            UICollectionView collection = new UICollectionView(this.View.Bounds, layout);

            collection.RegisterClassForCell(typeof(DSCollectionViewCell), "cell");
            collection.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            collection.DataSource       = this.dataSource;
            collection.BackgroundColor  = UIColor.White;
            this.View.AddSubview(collection);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            dataSource = new TKDataSource();

            dataSource.AddFilterDescriptor(new TKDataSourceFilterDescriptor("NOT (Name like 'John')"));
            dataSource.AddSortDescriptor(new TKDataSourceSortDescriptor("Name", true));
            dataSource.AddGroupDescriptor(new TKDataSourceGroupDescriptor("Group"));

            // >> datasource-feed-object-cs
            var array = new NSMutableArray();

            array.Add(new DSItem()
            {
                Name = "John", Value = 22.0f, Group = "one"
            });
            array.Add(new DSItem()
            {
                Name = "Peter", Value = 15.0f, Group = "one"
            });
            array.Add(new DSItem()
            {
                Name = "Abby", Value = 47.0f, Group = "one"
            });
            array.Add(new DSItem()
            {
                Name = "Robert", Value = 45.0f, Group = "two"
            });
            array.Add(new DSItem()
            {
                Name = "Alan", Value = 17.0f, Group = "two"
            });
            array.Add(new DSItem()
            {
                Name = "Saly", Value = 33.0f, Group = "two"
            });

            dataSource.DisplayKey = "Name";
            dataSource.ValueKey   = "Value";
            dataSource.ItemSource = array;
            // << datasource-feed-object-cs

            // >> datasource-text-cs
            dataSource.FormatText((NSObject item, TKDataSourceGroup group) => {
                DSItem dsItem = (DSItem)item;
                return(new NSString(string.Format("{0} has {1} points", dsItem.Name, dsItem.Value)));
            });
            // << datasource-text-cs

            var tableView = new UITableView(this.View.Bounds);

            tableView.DataSource = dataSource;
            this.View.AddSubview(tableView);
        }
 void AddItem(NSMutableArray array, string name, float value, string group, int day, UIImage image)
 {
     NSCalendar calendar = NSCalendar.CurrentCalendar;
     NSDateComponents components = new NSDateComponents ();
     components.Day = day;
     NSDate date = calendar.DateByAddingComponents (components, NSDate.Now, NSCalendarOptions.None);
     DSItem item = new DSItem () {
         Name = name,
         Value = value,
         Group = group,
         Date = date,
         Image = image
     };
     array.Add (item);
 }
        void AddItem(NSMutableArray array, string name, float value, string group, int day, UIImage image)
        {
            NSCalendar       calendar   = NSCalendar.CurrentCalendar;
            NSDateComponents components = new NSDateComponents();

            components.Day = day;
            NSDate date = calendar.DateByAddingComponents(components, NSDate.Now, NSCalendarOptions.None);
            DSItem item = new DSItem()
            {
                Name  = name,
                Value = value,
                Group = group,
                Date  = date,
                Image = image
            };

            array.Add(item);
        }