110,536
社区成员
发帖
与我相关
我的任务
分享
问题一:
第一步:
获取你需要改变背景的行。
DataGridRow row = (dg.ItemContainerGenerator.ContainerFromItem(dg.SelectedItem) as DataGridRow);
第二步:
得到单元格
List<DataGridCell> tbs = GetChildObjects<DataGridCell>(row, "");
第三步:
设置单元格样式
dataGrid.CellStyle = this.Resources["dgCellStyle"] as Style;
问题二:
你需要自定义combobox的样式:
在设计视图里,选中combobox,然后右键,编辑模板/编辑其他模板。
根据自动生成的样式代码,调整成你需要的样子。
DataGridRow dr = (DataGridRow)datag.ItemContainerGenerator.ContainerFromIndex(i);
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(dr);