Пример #1
0
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var cell = base.GetCell(item, reusableCell, tv);

            CellAccessory.Apply(item, cell);
            return(cell);
        }
Пример #2
0
        internal static void Apply(Cell cell, UITableViewCell nativeCell)
        {
            CellAccessory watchedCell = null;

            // look to see if we are already tracking this xaml cell
            foreach (var item in _watchedCells.ToArray())
            {
                Cell cellRef;
                if (item._cell.TryGetTarget(out cellRef))
                {
                    if (cellRef == cell)
                    {
                        watchedCell = item;
                        break;
                    }
                }
                else
                {
                    // remove dead entry from list
                    _watchedCells.Remove(item);
                }
            }

            // if not already tracking, set up new entry and monitor for property changes
            if (watchedCell == null)
            {
                watchedCell = new CellAccessory {
                    _cell = new WeakReference <Cell>(cell)
                };
                cell.PropertyChanged += watchedCell.CellPropertyChanged;
                _watchedCells.Add(watchedCell);
            }

            // update the target native cell of the tracked xaml cell
            watchedCell._nativeCell = new WeakReference <UITableViewCell>(nativeCell);

            // force immediate update of accessory type
            watchedCell.Reapply();
        }
        internal static void Apply(Cell cell, UITableViewCell nativeCell)
        {
            CellAccessory watchedCell = null;

            // look to see if we are already tracking this xaml cell
            foreach (var item in _watchedCells.ToArray())
            {
                Cell cellRef;
                if (item._cell.TryGetTarget(out cellRef))
                {
                    if (cellRef == cell)
                    {
                        watchedCell = item;
                        break;
                    }
                }
                else
                {
                    // remove dead entry from list
                    _watchedCells.Remove(item);
                }
            }

            // if not already tracking, set up new entry and monitor for property changes
            if (watchedCell == null)
            {
                watchedCell = new CellAccessory { _cell = new WeakReference<Cell>(cell) };
                cell.PropertyChanged += watchedCell.CellPropertyChanged;
                _watchedCells.Add(watchedCell);
            }

            // update the target native cell of the tracked xaml cell
            watchedCell._nativeCell = new WeakReference<UITableViewCell>(nativeCell);

            // force immediate update of accessory type
            watchedCell.Reapply();
        }