public void Bind(BlacklistItem contentItem, UIBlackListTableView parent) { _parent = parent; lblBlacklist.Text = contentItem.Value; btnDelete.SetImage (UIImage.FromFile ("images/icons/delete.png"), UIControlState.Normal); btnDelete.TouchUpInside += (object sender, EventArgs e) => { _parent.DeleteItem(_contentItem); }; _contentItem = contentItem; }
void Layout() { if (_tableView == null) { _tableView = new UIBlackListTableView (); var t = this.Frame; _tableView.Frame = new RectangleF (0, 0, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height - 44); // 44 is height of nav bar // _tableView.ScrollEnabled = false; _tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; _tableView.BackgroundColor = UIColor.FromRGB (242, 242, 242); //UIColor.FromPatternImage (UIImage.FromFile("images/login/loginBg.png")); // add a swipe handler for options var s = new UISwipeGestureRecognizer (SwipeHandler); s.Direction = UISwipeGestureRecognizerDirection.Left; _tableView.AddGestureRecognizer (s); s = new UISwipeGestureRecognizer (SwipeHandler); s.Direction = UISwipeGestureRecognizerDirection.Right; _tableView.AddGestureRecognizer (s); // wure up the remove row _tableView.DeleteItem = (item) => { var alert = MBAlertView.AlertWithBody ("Are you sure you want to delete this black list item? You cannot undo this.", "No", null); alert.AddButtonWithText ("Yes", MBAlertViewItemType.Destructive, () => { // call server to delete the tweet Helper.Default.ShowHud("deleting ..."); Api.Default.DeleteBlackListItem (item.Value, (result) => { this.InvokeOnMainThread(()=>{ if (result.Result == "ok") { var index = this.ViewSource.RemoveItem (item); this._tableView.DeleteRows (new MonoTouch.Foundation.NSIndexPath[]{MonoTouch.Foundation.NSIndexPath.Create (0,index)}, UITableViewRowAnimation.Fade); Helper.Default.HideHud(); } else{ Helper.Default.HideHud("Could not delete, try again."); } }); }); }); alert.AddToDisplayQueue (); }; // add to view this.AddSubview (_tableView); } }