public TodoViewController () { Title = "Todo Items"; TableView.Source = DataSource = new ViewModelDataSource<TodoItem>{ CellForItem = (tv,item)=>{ var cell = tv.DequeueReusableCell<TodoItemCell>(TodoItemCell.Key); cell.Item = item; return cell; }, ViewModel = (viewModel = new TodoViewModel()), }; viewModel.ItemsChanged += (object sender, EventArgs e) => TableView.ReloadData(); }
public ContactsViewController () { Title = "Contacts"; var items = Database.Contacts.Table<Person> (); TableView.Source = DataSource = new ViewModelDataSource<Person>{ CellForItem = (tv,item)=>{ var cell = tv.DequeueReusableCell<ContactCell>(ContactCell.Key); cell.Contact = item; return cell; }, ViewModel = (viewModel = new EnumerableViewModel<Person>{ Items = items, }), }; }
public ContactsViewController () { Title = "Contacts"; // TODO: Step 1 Add .ToList() to force this to evaluate and cache off to a list. var items = Database.Contacts.Table<Person> ().ToList(); TableView.Source = DataSource = new ViewModelDataSource<Person>{ CellForItem = (tv,item)=>{ var cell = tv.DequeueReusableCell<ContactCell>(ContactCell.Key); cell.Contact = item; return cell; }, ViewModel = (viewModel = new EnumerableViewModel<Person>{ Items = items, }), }; }
protected override void OnEnable() { base.OnEnable(); mTarget = this.target as ViewModelDataSource; }