コード例 #1
0
        /// <summary>
        /// Arranges the content of the <see cref="T:System.Windows.Controls.Primitives.DataGridCellsPresenter"/>.
        /// </summary>
        /// <returns>
        /// The actual size used by the <see cref="T:System.Windows.Controls.Primitives.DataGridCellsPresenter"/>.
        /// </returns>
        /// <param name="finalSize">
        /// The final area within the parent that this element should use to arrange itself and its children.
        /// </param>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (this.OwningGrid == null)
            {
                return(base.ArrangeOverride(finalSize));
            }

            if (this.OwningGrid.AutoSizingColumns)
            {
                // When we initially load an auto-column, we have to wait for all the rows to be measured
                // before we know its final desired size.  We need to trigger a new round of measures now
                // that the final sizes have been calculated.
                this.OwningGrid.AutoSizingColumns = false;
                return(base.ArrangeOverride(finalSize));
            }

            double frozenLeftEdge    = 0;
            double scrollingLeftEdge = -this.OwningGrid.HorizontalOffset;

            double cellLeftEdge;

            foreach (DataGridColumn column in this.OwningGrid.ColumnsInternal.GetVisibleColumns())
            {
                DataGridCell cell = this.OwningRow.Cells[column.Index];
                Debug.Assert(cell.OwningColumn == column, "Expected column owner.");
                Debug.Assert(column.IsVisible, "Expected visible column.");

                if (column.IsFrozen)
                {
                    cellLeftEdge = frozenLeftEdge;

                    // This can happen before or after clipping because frozen cells aren't clipped
                    frozenLeftEdge += column.ActualWidth;
                }
                else
                {
                    cellLeftEdge = scrollingLeftEdge;
                }

                if (cell.Visibility == Visibility.Visible)
                {
                    cell.Arrange(new Rect(cellLeftEdge, 0, column.LayoutRoundedWidth, finalSize.Height));
                    EnsureCellClip(cell, column.ActualWidth, finalSize.Height, frozenLeftEdge, scrollingLeftEdge);
                }

                scrollingLeftEdge += column.ActualWidth;
                column.IsInitialDesiredWidthDetermined = true;
            }

            _fillerLeftEdge = scrollingLeftEdge;

            // FillerColumn.Width == 0 when the filler column is not active
            this.OwningRow.FillerCell.Arrange(new Rect(_fillerLeftEdge, 0, this.OwningGrid.ColumnsInternal.FillerColumn.FillerWidth, finalSize.Height));

            return(finalSize);
        }
コード例 #2
0
ファイル: DataGridCellsPresenter.cs プロジェクト: ynkbt/moon
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (this.OwningGrid != null)
            {
                double         frozenLeftEdge    = 0;
                double         scrollingLeftEdge = -this.OwningGrid.HorizontalOffset;
                double         cellLeftEdge;
                DataGridColumn column = this.OwningGrid.ColumnsInternal.FirstVisibleColumn;
                Debug.Assert(column == null || column.DisplayIndex >= 0);
                while (column != null)
                {
                    DataGridCell cell = this.OwningRow.Cells[column.Index];
                    Debug.Assert(cell.OwningColumn == column);
                    Debug.Assert(column.Visibility == Visibility.Visible);

                    if (column.IsFrozen)
                    {
                        cellLeftEdge = frozenLeftEdge;
                        // This can happen before or after clipping because frozen cells aren't clipped
                        frozenLeftEdge += column.ActualWidth;
                    }
                    else
                    {
                        cellLeftEdge = scrollingLeftEdge;
                    }
                    if (cell.Visibility == Visibility.Visible)
                    {
                        cell.Arrange(new Rect(cellLeftEdge, 0, column.ActualWidth, finalSize.Height));
                        EnsureCellClip(cell, column.ActualWidth, finalSize.Height, frozenLeftEdge, scrollingLeftEdge);
                    }
                    scrollingLeftEdge += column.ActualWidth;

                    column = this.OwningGrid.ColumnsInternal.GetNextVisibleColumn(column);
                }

                _fillerLeftEdge = scrollingLeftEdge;
                // FillerColumn.Width == 0 when the filler column is not active
                this.OwningRow.FillerCell.Arrange(new Rect(_fillerLeftEdge, 0, this.OwningGrid.ColumnsInternal.FillerColumn.Width, finalSize.Height));

                return(finalSize);
            }
            return(base.ArrangeOverride(finalSize));
        }