예제 #1
0
        public static DataGridCell GetCell(this DataGrid grid, DataGridRow row, int columnIndex = 0)
        {
            if (row == null)
            {
                return(null);
            }

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

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

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

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

            grid.ScrollIntoView(row, grid.Columns[columnIndex]);
            cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);

            return(cell);
        }