DataGrid加载事件:
private void dgvNotesManage_LoadingRow(object sender, DataGridRowEventArgs e)
{
try
{
DataRowView drv = e.Row.Item as DataRowView;
if (drv != null)
{
if (!drv["NoteCategory"].ToString().IsNullOrEmpty())
{
if (drv["NoteCategory"].ToString().Trim() == "重要")
{
e.Row.Foreground = new SolidColorBrush(Colors.Red);//前景色即字体的颜色
e.Row.Background = new SolidColorBrush(Colors.Red);//背景色
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}