目前我实现了这个功能,但是每当我选定别的TabItem再切回来的时候,单元格的颜色就会消失,我该怎么修改呢?
{
dataGrid = sender as DataGrid;
if (tabbarControl.SelectedIndex == 0)
{
var cell = dataGrid.GetCell(1, 1);
if (cell != null)
{
cell.IsEnabled = false;
cell.Background = Brushes.LightBlue;
cell.Foreground = Brushes.LightBlue;
}
}
else
{
var cell = dataGrid.GetCell(1, 1);
if (cell != null)
{
cell.IsEnabled = false;
cell.Background = Brushes.Red;
}
}
IsLoad = true;
}
这里我通过这个GridView的Loaded事件改变了1行1列这个Cell的颜色 ,但是当我切换到别的tabitem的时候 再切换回来颜色就会消失