예제 #1
0
 /// <summary>
 /// Gets the cell.
 /// </summary>
 /// <param name="dataGrid">The data grid.</param>
 /// <param name="rowContainer">The row container.</param>
 /// <param name="column">The column.</param>
 /// <returns></returns>
 public static DataGridCell GetCell(this DataGrid dataGrid, DataGridRow rowContainer, int column)
 {
     if (rowContainer != null)
     {
         DataGridCellsPresenter presenter = rowContainer.FindVisualChild <DataGridCellsPresenter>();
         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 = rowContainer.FindVisualChild <DataGridCellsPresenter>();
         }
         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);
 }
예제 #2
0
        public static DataGridCell GetCell(this DataGrid grid, DataGridRow row, int columnIndex = 0)
        {
            if (row == null)
            {
                return(null);
            }

            var presenter = row.FindVisualChild <DataGridCellsPresenter>();

            if (presenter == null)
            {
                return(null);
            }

            var cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);

            if (cell != null)
            {
                return(cell);
            }

            // now try to bring into view and retreive the cell
            grid.ScrollIntoView(row, grid.Columns[columnIndex]);
            cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);

            return(cell);
        }
예제 #3
0
 public static DataGridCellsPresenter GetPresenter(DataGridRow row)
 {
     return(row.FindVisualChild <DataGridCellsPresenter>());
 }