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) { this.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); } }
internal override void PrepareCell(GridCellModel cell) { base.PrepareCell(cell); var textBlock = cell.Container as TextBlock; if (textBlock == null) { return; } bool?value = (bool?)cell.Value; if (value.HasValue) { textBlock.Text = value.Value ? CheckedGlyph : UncheckedGlyph; } else { textBlock.Text = IndeterminateGlyph; } }
internal async void Select(GridCellModel gridCellModel) { var dataGridPeer = FrameworkElementAutomationPeer.FromElement(this.Owner) as RadDataGridAutomationPeer; if (dataGridPeer != null && dataGridPeer.childrenCache != null) { if (dataGridPeer.childrenCache.Count == 0) { dataGridPeer.GetChildren(); } var cellPeer = dataGridPeer.childrenCache.Where(a => a.Row == gridCellModel.ParentRow.ItemInfo.Slot && a.Column == gridCellModel.Column.ItemInfo.Slot).FirstOrDefault() as DataGridCellInfoAutomationPeer; if (cellPeer != null && cellPeer.ChildTextBlockPeer != null) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { cellPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); cellPeer.RaiseValuePropertyChangedEvent(false, true); }); } } switch (this.Owner.SelectionUnit) { case DataGridSelectionUnit.Row: this.SelectItem((gridCellModel.Parent as GridRowModel).ItemInfo.Item, true, true); break; case DataGridSelectionUnit.Cell: var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column); this.SelectCellInfo(cellInfo, true, true); break; default: throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit"); } }
private RadSize MeasureCell(GridCellModel cell) { ContentLayer layer = this.GetContentLayerForColumn(cell.Column); // 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; RadSize size = GridModel.DoubleArithmetics.Ceiling(layer.MeasureCell(cell, availableWidth).ToRadSize()); if (this.HasHorizontalGridLines && !this.decorationLayerCache.IsFirstLine(cell.ParentRow.ItemInfo)) { size.Height += this.GridLinesThickness; } if (this.HasVerticalGridLines) { size.Width += this.GridLinesThickness; } cell.DesiredSize = size; cell.Column.AutoWidth = Math.Max(cell.Column.AutoWidth, size.Width); return(cell.DesiredSize); }
internal void UpdateHoverDecoration(GridCellModel hoveredNode) { RadRect slot; switch (this.Owner.SelectionUnit) { case DataGridSelectionUnit.Row: var row = hoveredNode == null ? null : hoveredNode.parent; slot = row != null ? row.LayoutSlot : RadRect.Empty; this.Owner.visualStateLayerCache.UpdateHoverDecoration(slot); this.Owner.frozenVisualStateLayerCache.UpdateHoverDecoration(slot); break; case DataGridSelectionUnit.Cell: slot = hoveredNode != null ? hoveredNode.LayoutSlot : RadRect.Empty; this.Owner.visualStateLayerCache.UpdateHoverDecoration(slot); this.Owner.frozenVisualStateLayerCache.UpdateHoverDecoration(slot); break; default: break; } }
internal virtual RadSize MeasureCell(GridCellModel cell, double availableWidth) { // This method is called by the XamlContentLayer RadSize size = RadSize.Empty; if (this.sizeModeCache == DataGridColumnSizeMode.Fixed) { availableWidth = this.widthCache; } UIElement container = cell.Container as UIElement; if (container != null) { size = this.MeasureCellContainer(availableWidth, container).ToRadSize(); } if (this.sizeModeCache == DataGridColumnSizeMode.Fixed) { size.Width = this.widthCache; } return(size); }
internal void ClearCell(GridCellModel cell) { this.ClearCell(cell.Container); }
internal void PrepareCell(GridCellModel cell) { this.PrepareCell(cell.Container, cell.Value, cell.ParentRow?.ItemInfo.Item); }
internal virtual void ClearCell(GridCellModel cell) { }
internal abstract void PrepareCell(GridCellModel cell);
internal DataGridCellInfo(GridCellModel cellModel) { this.RowItemInfo = cellModel.ParentRow.ItemInfo; this.Column = cellModel.Column; this.Cell = cellModel; }