Esempio n. 1
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int  sectionIndex;
            bool isHeader;
            int  itemIndexInSection;

            GetComputedIndexes(row, out sectionIndex, out itemIndexInSection, out isHeader);

            string id;
            Cell   cell;

            if (isHeader)
            {
                id   = HeaderIdentifier;
                cell = Controller.Model.GetHeaderCell(sectionIndex) ??
                       new TextCell {
                    Text = Controller.Model.GetSectionTitle(sectionIndex)
                };
            }
            else
            {
                id   = ItemIdentifier;
                cell = Controller.Model.GetCell(sectionIndex, itemIndexInSection);
            }

            var nativeCell = CellNSView.GetNativeCell(tableView, cell, id, isHeader);

            return(nativeCell);
        }
Esempio n. 2
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            var  sectionIndex       = 0;
            var  itemIndexInSection = (int)row;
            Cell cell;

            var isHeader = false;

            if (IsGroupingEnabled)
            {
                GetComputedIndexes(row, out sectionIndex, out itemIndexInSection, out isHeader);
            }

            var indexPath  = NSIndexPath.FromItemSection(itemIndexInSection, sectionIndex);
            var templateId = isHeader ? "headerCell" : TemplateIdForPath(indexPath).ToString();

            NSView nativeCell;

            var cachingStrategy = Controller.CachingStrategy;

            if (cachingStrategy == ListViewCachingStrategy.RetainElement)
            {
                cell       = GetCellForPath(indexPath, isHeader);
                nativeCell = CellNSView.GetNativeCell(tableView, cell, templateId, isHeader);
            }
            else if (cachingStrategy == ListViewCachingStrategy.RecycleElement)
            {
                nativeCell = tableView.MakeView(templateId, tableView);
                if (nativeCell == null)
                {
                    cell       = GetCellForPath(indexPath, isHeader);
                    nativeCell = CellNSView.GetNativeCell(tableView, cell, templateId, isHeader, true);
                }
                else
                {
                    var templatedList = TemplatedItemsView.TemplatedItems.GetGroup(sectionIndex);
                    cell = (Cell)((INativeElementView)nativeCell).Element;
                    ICellController controller = cell;
                    controller.SendDisappearing();
                    templatedList.UpdateContent(cell, itemIndexInSection);
                    controller.SendAppearing();
                }
            }
            else
            {
                throw new NotSupportedException();
            }
            return(nativeCell);
        }