grid.Model.QueryCellInfo += Model_QueryCellInfo;
grid.Model.SelectionChanged += Model_SelectionChanged;
private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
//Invalidate the corresponding Header rows and colums when selection is changed.
grid.Model.InvalidateCell(GridRangeInfo.Cols(0, grid.Model.HeaderColumns - 1));
grid.Model.InvalidateCell(GridRangeInfo.Rows(0, grid.Model.HeaderRows - 1));
grid.Model.InvalidateVisual();
}
private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
//Modify the background of header cells based on cell selection.
if ((e.Cell.RowIndex == grid.Model.HeaderRows - 1 && grid.Model.SelectedRanges.AnyRangeIntersects(GridRangeInfo.Col(e.Cell.ColumnIndex)))
|| (e.Cell.ColumnIndex == grid.Model.HeaderColumns - 1 && grid.Model.SelectedRanges.AnyRangeIntersects(GridRangeInfo.Row(e.Cell.RowIndex))))
{
e.Style.Background = new SolidColorBrush(Colors.DarkOrange);
}
if (e.Cell.RowIndex == 0 && e.Cell.ColumnIndex == 0)
return;
if (e.Cell.RowIndex == 0)
e.Style.CellValue = GridRangeInfo.GetAlphaLabel(e.Cell.ColumnIndex);
else if(e.Cell.ColumnIndex == 0)
e.Style.CellValue = e.Cell.RowIndex;
} |