public override void CommitEditingStyle(RATreeView treeView, UITableViewCellEditingStyle editingStyle, NSObject item)
            {
                //base.CommitEditingStyle(treeView, editingStyle, item);
                if (editingStyle != UITableViewCellEditingStyle.Delete)
                {
                    return;
                }
                var i      = item as DataObject;
                var parent = treeView.ParentForItem(i) as DataObject;

                int index;

                if (parent != null)
                {
                    index = parent.Children.FindIndex((dataObject) =>
                    {
                        return(dataObject == i);
                    });
                    parent.RemoveChild(i);
                }
                else
                {
                    index = this.Data.FindIndex((dataObject) =>
                    {
                        return(dataObject == i);
                    });
                    this.Data.RemoveAt(index);
                }

                treeView.DeleteItemsAtIndexes(new NSIndexSet((uint)index), parent, RATreeViewRowAnimation.Right);
                treeView.ReloadRowsForItems(new NSObject[] { parent }, RATreeViewRowAnimation.None);
            }
 private void SetupTreeView()
 {
     TreeView = new RATreeView(frame: View.Bounds, style: RATreeViewStyle.Plain);
     TreeView.RegisterNibForCell(TreeTableViewCell.Nib, TreeTableViewCell.Key);
     TreeView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
     TreeView.Delegate         = new TreeViewDelegate();
     TreeView.DataSource       = new TreeViewDataSource(Data);
     TreeView.TreeFooterView   = new UIView();
     TreeView.BackgroundColor  = UIColor.Clear;
     View.AddSubview(TreeView);
     TreeView.NumberOfRows();
 }
            public override nint NumberOfChildrenOfItem(RATreeView treeView, NSObject item)
            {
                var i = item as DataObject;

                if (i != null)
                {
                    return(i.Children.Count);
                }
                else
                {
                    return(Data.Count);
                }
            }
            public override NSObject GetChildItemAtIndexOfItem(RATreeView treeView, nint index, NSObject item)
            {
                var i = item as DataObject;

                if (i != null)
                {
                    return(i.Children[(int)index]);
                }
                else
                {
                    return(Data[(int)index]);
                }
            }
            public override UITableViewCell GetCell(RATreeView treeView, NSObject item)
            {
                var cell = treeView.DequeueReusableCellWithIdentifier(TreeTableViewCell.Key) as TreeTableViewCell;
                var i    = item as DataObject;

                var level       = treeView.LevelForCellForItem(i);
                var detailsText = string.Format("Number of children {0}", i.Children.Count);
                var expanded    = treeView.IsCellForItemExpanded(i);

                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
                cell.Setup(i.Name, detailsText, level, !expanded);
                cell.AdditionButtonActionBlock = (_) =>
                {
                    var newItem = new DataObject(name: "Added value");
                    i.AddChild(newItem);
                    treeView.InsertItemsAtIndexes(new NSIndexSet((nuint)i.Children.Count - 1), i, RATreeViewRowAnimation.None);
                    treeView.ReloadRowsForItems(new NSObject[] { i }, RATreeViewRowAnimation.None);
                };

                return(cell);
            }
            public override void WillCollapseRowForItem(RATreeView treeView, NSObject item)
            {
                var cell = treeView.CellForItem(item) as TreeTableViewCell;

                cell.AdditionalButtonHidden = true;
            }
 public override nfloat HeightForRowForItem(RATreeView treeView, NSObject item)
 {
     return(44);
 }
 public override bool CanEditRow(RATreeView treeView, NSObject item)
 {
     return(true);
 }