コード例 #1
0
ファイル: ItemsViewController.cs プロジェクト: zhamppx97/maui
        protected virtual void UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)
        {
            cell.ContentSizeChanged      -= CellContentSizeChanged;
            cell.LayoutAttributesChanged -= CellLayoutAttributesChanged;

            var bindingContext = ItemsSource[indexPath];

            // If we've already created a cell for this index path (for measurement), re-use the content
            if (_measurementCells.TryGetValue(bindingContext, out TemplatedCell measurementCell))
            {
                _measurementCells.Remove(bindingContext);
                measurementCell.ContentSizeChanged      -= CellContentSizeChanged;
                measurementCell.LayoutAttributesChanged -= CellLayoutAttributesChanged;
                cell.UseContent(measurementCell);
            }
            else
            {
                cell.Bind(ItemsView.ItemTemplate, ItemsSource[indexPath], ItemsView);
            }

            cell.ContentSizeChanged      += CellContentSizeChanged;
            cell.LayoutAttributesChanged += CellLayoutAttributesChanged;

            ItemsViewLayout.PrepareCellForLayout(cell);
        }
コード例 #2
0
        void UpdateTemplatedSupplementaryView(TemplatedCell cell, NSString elementKind, NSIndexPath indexPath)
        {
            DataTemplate template = elementKind == UICollectionElementKindSectionKey.Header
                                ? ItemsView.GroupHeaderTemplate
                                : ItemsView.GroupFooterTemplate;

            var bindingContext = ItemsSource.Group(indexPath);

            cell.Bind(template, bindingContext, ItemsView);

            if (cell is ItemsViewCell)
            {
                cell.ConstrainTo(GetLayoutSpanCount() * ItemsViewLayout.ConstrainedDimension);
            }
        }