Inheritance: Telerik.UI.Xaml.Controls.Grid.GridCellModel, IItemInfoNode
Ejemplo n.º 1
0
        private void ArrangeHeaderCell(GridHeaderCellModel cell)
        {
            var container = cell.Container as DataGridColumnHeader;

            if (container == null)
            {
                return;
            }

            cell.Column.LayoutWidth = cell.layoutSlot.Width;
            cell.Column.ActualWidth = cell.layoutSlot.Width;
            if (this.HasVerticalGridLines)
            {
                cell.Column.ActualWidth -= this.gridLinesThicknessCache;
            }

            var rect = this.InflateCellHorizontally(cell, cell.layoutSlot);

            Canvas.SetLeft(container, rect.X);
            Canvas.SetTop(container, rect.Y);

            // A HACK to overcome the differences in the DesiredSize of the header and the ArrangeSize, coming from the NodePool.
            container.AllowArrange = true;

            container.ArrangeRestriction = new Size(rect.Width, rect.Height);

            // The InvalidateArrange call is needed as the arrange size may be same and an actual Arrange pass will not be triggered
            container.InvalidateArrange();
            container.Arrange(rect.ToRect());

            container.AllowArrange = false;
        }
Ejemplo n.º 2
0
        RadSize IElementPresenter.MeasureContent(object owner, object content)
        {
            GridRowModel row = owner as GridRowModel;

            if (row != null)
            {
                return(this.MeasureRow(row));
            }

            GridHeaderCellModel headerCell = owner as GridHeaderCellModel;

            if (headerCell != null)
            {
                return(this.MeasureHeaderCell(headerCell));
            }

            GridCellEditorModel editCell = owner as GridCellEditorModel;

            if (editCell != null)
            {
                return(this.MeasureEditCell(editCell));
            }

            GridCellModel cell = owner as GridCellModel;

            if (cell != null)
            {
                return(this.MeasureCell(cell));
            }

            return(RadSize.Empty);
        }
Ejemplo n.º 3
0
        private RadSize MeasureHeaderCell(GridHeaderCellModel cell)
        {
            // TODO: consider if content needs to be measured with constraint in stretch mode.
            var availableWidth = cell.Column.SizeMode == DataGridColumnSizeMode.Fixed ? cell.Column.Width : double.PositiveInfinity;
            var size           = GridModel.DoubleArithmetics.Ceiling(cell.Column.MeasureCell(cell, availableWidth));

            if (this.HasVerticalGridLines)
            {
                size.Width -= this.GridLinesThickness;
            }

            cell.DesiredSize      = size;
            cell.Column.AutoWidth = Math.Max(cell.Column.AutoWidth, size.Width);

            return(cell.DesiredSize);
        }
Ejemplo n.º 4
0
        void IGridView.Arrange(Node node)
        {
            GridEditRowModel editRow = node as GridEditRowModel;

            if (editRow != null)
            {
                this.ArrangeEditRow(editRow);
                return;
            }

            GridRowModel row = node as GridRowModel;

            if (row != null)
            {
                RadDataGrid.ArrangeRow(row);
                return;
            }

            GridHeaderCellModel headerCell = node as GridHeaderCellModel;

            if (headerCell != null)
            {
                this.ArrangeHeaderCell(headerCell);
                return;
            }

            GridCellEditorModel editCell = node as GridCellEditorModel;

            if (editCell != null)
            {
                this.ArrangeEditorCell(editCell);
            }

            GridCellModel cell = node as GridCellModel;

            if (cell != null)
            {
                this.ArrangeCell(cell);
            }
        }
Ejemplo n.º 5
0
        internal virtual void ClearColumnHeaderCell(GridHeaderCellModel cell)
        {
            this.headerControl = null;

            // TODO: Consider which properties should be cleared in order to avoid memory leaks.
            var header = cell.Container as DataGridColumnHeader;

            if (header == null)
            {
                Debug.Assert(false, "Unknown column decorator");
                return;
            }

            header.ClearValue(FrameworkElement.WidthProperty);
            header.ClearValue(FrameworkElement.HeightProperty);
            header.Column  = null;
            header.Owner   = null;
            header.Content = null;

            //// TODO: Is this the best place to reset the AutoWidth?
            //// TODO: Not resetting AutoWidth causes weird behavior upon editing - if you add long text value, the column grows and then if you delete the long text, the column stays wide
            ////this.AutoWidth = 0;
        }
Ejemplo n.º 6
0
        internal virtual void PrepareColumnHeaderCell(GridHeaderCellModel cell)
        {
            var header = cell.Container as DataGridColumnHeader;

            if (header == null)
            {
                Debug.Assert(false, "Unknown column decorator");
                return;
            }

            this.headerControl = new WeakReference <DataGridColumnHeader>(header);

            header.Column     = this;
            header.Content    = this.Header;
            header.IsFiltered = this.isFiltered;

            ((IReorderItem)header).LogicalIndex = cell.ItemInfo.LayoutInfo.Line;

            // Force update of all bindings. This is needed since any binding to dependency property does not recieve notification when property is changed.
            header.DataContext           = null;
            header.DataContext           = cell.ItemInfo.Item;
            header.Owner                 = this.Model.GridView as RadDataGrid;
            header.FilterGlyphVisibility = this.CanFilter && header.Owner.ColumnDataOperationsMode == ColumnDataOperationsMode.Inline ? Visibility.Visible : Visibility.Collapsed;

            header.ResizeHandleVisiblity = this.CanUserResize && header.Owner.ColumnResizeHandleDisplayMode == DataGridColumnResizeHandleDisplayMode.Always ? Visibility.Visible : Visibility.Collapsed;

            header.IsSelected = this == header.Owner.LastSelectedColumn;

            if (this.headerStyleCache != null)
            {
                header.Style = this.headerStyleCache;
            }
            else
            {
                header.ClearValue(FrameworkElement.StyleProperty);
            }

            if (cell.ItemInfo.LayoutInfo.Line == this.Model.ColumnPool.Layout.ItemsSource.Count - 1)
            {
                // Apply padding when last column to offset from column chooser button.
                if (header.Owner.CanUserChooseColumns)
                {
                    if (this.headerStyleCache != null && this.headerStyleCache.Setters.OfType <Setter>().Any(c => c.Property == DataGridColumnHeader.PaddingProperty))
                    {
                        var oldPadding = (Thickness)this.headerStyleCache.Setters.OfType <Setter>().First(c => c.Property == DataGridColumnHeader.PaddingProperty).Value;
                        header.Padding = new Thickness(oldPadding.Left, oldPadding.Top, oldPadding.Right + header.Owner.ColumnReorderServicePanel.ActualWidth, oldPadding.Bottom);
                    }
                    else
                    {
                        header.Padding = new Thickness(0, 0, header.Owner.ColumnReorderServicePanel.ActualWidth, 0);
                    }
                }
                else
                {
                    if (this.headerStyleCache != null && this.headerStyleCache.Setters.OfType <Setter>().Any(c => c.Property == DataGridColumnHeader.PaddingProperty))
                    {
                        var oldPadding = (Thickness)this.headerStyleCache.Setters.OfType <Setter>().First(c => c.Property == DataGridColumnHeader.PaddingProperty).Value;
                        header.Padding = oldPadding;
                    }
                    else
                    {
                        header.Padding = new Thickness(0);
                    }
                }
            }
        }