private static DataGridCell GetCell(DataGrid dataGrid, DataGridRow rowContainer, int column) { if (rowContainer != null) { System.Windows.Controls.Primitives.DataGridCellsPresenter presenter = FindVisualChild <System.Windows.Controls.Primitives.DataGridCellsPresenter>(rowContainer); if (presenter == null) { /* if the row has been virtualized away, call its ApplyTemplate() method * to build its visual tree in order for the DataGridCellsPresenter * and the DataGridCells to be created */ rowContainer.ApplyTemplate(); presenter = FindVisualChild <System.Windows.Controls.Primitives.DataGridCellsPresenter>(rowContainer); } if (presenter != null) { DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell; if (cell == null) { /* bring the column into view * in case it has been virtualized away */ dataGrid.ScrollIntoView(rowContainer, dataGrid.Columns[column]); cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell; } return(cell); } } return(null); }
public DataGridCell GetCell(int row, int column) { DataGridRow dgr = (DataGridRow)this.ItemContainerGenerator.ContainerFromIndex(row); System.Windows.Controls.Primitives.DataGridCellsPresenter presenter = DataGridHelper.GetVisualChild <System.Windows.Controls.Primitives.DataGridCellsPresenter>(dgr); return((DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column)); }
/// <summary> /// Builds the visual tree for the column header when a new template is applied. /// </summary> public override void OnApplyTemplate() { this.RootElement = GetTemplateChild(DATAGRIDROW_elementRoot) as Panel; // if (this.RootElement != null) { EnsureBackground(); ApplyState(false /*animate*/); } bool updateVerticalScrollBar = false; if (this._cellsElement != null) { // If we're applying a new template, we want to remove the cells from the previous _cellsElement this._cellsElement.Children.Clear(); updateVerticalScrollBar = true; } this._cellsElement = GetTemplateChild(DATAGRIDROW_elementCells) as DataGridCellsPresenter; if (this._cellsElement != null) { this._cellsElement.OwningRow = this; // Cells that were already added before the Template was applied need to // be added to the Canvas if (this.Cells.Count > 0) { foreach (DataGridCell cell in this.Cells) { this._cellsElement.Children.Add(cell); } } } _detailsElement = GetTemplateChild(DATAGRIDROW_elementDetails) as DataGridDetailsPresenter; if (_detailsElement != null && this.OwningGrid != null) { _detailsElement.OwningRow = this; if (this.ActualDetailsVisibility == Visibility.Visible && this.ActualDetailsTemplate != null && this._appliedDetailsTemplate == null) { // Apply the DetailsTemplate now that the row template is applied. SetDetailsVisibilityInternal(this.ActualDetailsVisibility, _detailsVisibilityNotificationPending /*raiseNotification*/, false /*animate*/); _detailsVisibilityNotificationPending = false; } } _bottomGridLine = GetTemplateChild(DATAGRIDROW_elementBottomGridLine) as Rectangle; EnsureGridLines(); _headerElement = GetTemplateChild(DATAGRIDROW_elementRowHeader) as DataGridRowHeader; if (_headerElement != null) { _headerElement.Owner = this; if (this.Header != null) { _headerElement.Content = Header; } EnsureHeaderStyleAndVisibility(null); } // The height of this row might have changed after applying a new style, so fix the vertical scroll bar if (this.OwningGrid != null && updateVerticalScrollBar) { this.OwningGrid.UpdateVerticalScrollBar(); } }
// Token: 0x06005CA4 RID: 23716 RVA: 0x001A1080 File Offset: 0x0019F280 private static object OnCoerceIsVirtualizingProperty(DependencyObject d, object baseValue) { DataGridCellsPresenter dataGridCellsPresenter = d as DataGridCellsPresenter; return(DataGridHelper.GetCoercedTransferPropertyValue(dataGridCellsPresenter, baseValue, VirtualizingPanel.IsVirtualizingProperty, dataGridCellsPresenter.DataGridOwner, DataGrid.EnableColumnVirtualizationProperty)); }
// Token: 0x06005C93 RID: 23699 RVA: 0x001A0CAC File Offset: 0x0019EEAC private static object OnCoerceMinHeight(DependencyObject d, object baseValue) { DataGridCellsPresenter dataGridCellsPresenter = d as DataGridCellsPresenter; return(DataGridHelper.GetCoercedTransferPropertyValue(dataGridCellsPresenter, baseValue, FrameworkElement.MinHeightProperty, dataGridCellsPresenter.DataGridOwner, DataGrid.MinRowHeightProperty)); }