WPF设置表格行格式
设置行格式可以通过LoadingRow事件实现
LoadingRow事件可以直接访问行数据对象,可以直接设置行
例子:
当数据表格中的状态为true时,设置表格行的颜色为粉红色,false是为白色
private SolidColorBrush pink= new SolidColorBrush(Colors.Pink);
private SolidColorBrush white = new SolidColorBrush(Colors.White);
private void DA_LoadingRow(object sender, DataGridRowEventArgs e)
{
Registrationvo list = (Registrationvo)e.Row.DataContext;
if (list.RegistrationCAN == true)
{
e.Row.Background = pink;
}
else
{
e.Row.Background = white;
}
}