Esempio n. 1
0
        //Or we can simply select a row by its indices:

        public static DataGridCell GetCell(ref System.Windows.Controls.DataGrid grid, int row, int column)
        {
            DataGridRow rowContainer = GetRow(ref grid, row);

            return(GetCell(ref grid, rowContainer, column));
        }
Esempio n. 2
0
        //Now we can get a cell of a DataGrid by an existing row:

        public static DataGridCell GetCell(ref System.Windows.Controls.DataGrid grid, DataGridRow row, int column)
        {
            if (row != null)
            {
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row);

                if (presenter == null)
                {
                    grid.ScrollIntoView(row, grid.Columns[column]);
                    presenter = GetVisualChild <DataGridCellsPresenter>(row);
                }

                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                return(cell);
            }
            return(null);
        }