标签:color wpf orb 方法 null void pre com code
public void Color()
{
DataGridRow row1 = (DataGridRow)this.dgSource.ItemContainerGenerator.ContainerFromIndex(i); if (row1 != null) row1.Background = new SolidColorBrush(Colors.Red);
}
这里有个坑,初始化时不能变色,必须等datagrid完成渲染后才能进行这种行变色。
因而先把form show 出来之后才执行变色方法。
CompareForm cf = new CompareForm(); cf.Show(); cf.Color();
标签:color wpf orb 方法 null void pre com code
原文地址:https://www.cnblogs.com/cvol/p/10647833.html