示例#1
0
        public static TextBlock GetTextBlock(DataGridRow rowContainer, int column)
        {
            DataGridCellsPresenter presenter    = FindControl.FindChild <DataGridCellsPresenter>(rowContainer, string.Empty);
            DataGridCell           datagridCell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);

            return(GetTextBlock(datagridCell));
        }
示例#2
0
        public static TextBlock GetTextBlock(DataGridCell datagridCell)
        {
            var framework = FindControl.FindChild <FrameworkElement>((ContentPresenter)datagridCell.Content, string.Empty);
            var textBlock = framework as TextBlock;

            return(textBlock);
        }
示例#3
0
        public static DataGridCell GetCell(DataGrid datagrid, int row, int column)
        {
            DataGridRow rowContainer = GetRow(datagrid, row);

            if (rowContainer != null)
            {
                DataGridCellsPresenter presenter = FindControl.FindChild <DataGridCellsPresenter>(rowContainer, string.Empty);
                if (presenter == null)
                {
                    datagrid.ScrollIntoView(rowContainer, datagrid.Columns[column]);
                    presenter = FindControl.FindChild <DataGridCellsPresenter>(rowContainer, string.Empty);
                }
                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                return(cell);
            }
            return(null);
        }