sdk:DataGrid数据绑定后,部分特殊的行需要用不同的背景颜色来显示。(注册DataGrid的LoadingRow事件)
1 private void radGridView_LoadingRow(object sender, DataGridRowEventArgs e) 2 { 3 4 //获取当前加载的行标(从0开始) 5 int i = e.Row.GetIndex(); 6 7 //获取DataGrid绑定的数据集合 8 ObservableCollection<CntrMstModel> list = radGridView.ItemsSource as ObservableCollection<CntrMstModel>; 9 10 //遍历集合 11 12 foreach (CntrMstModel model in list) 13 { 14 if (i.ToString() == model.SID) 15 { 16 17 //改变颜色的行条件 18 if (model.ID == "1") 19 e.Row.Background = new SolidColorBrush(Colors.Gray); 20 else 21 e.Row.Background = new SolidColorBrush(Colors.White); 22 } 23 } 24 } 25 26