我想在后面的代码中动态更改所选的行颜色。我正在使用Visual Studio 2008.任何人都可以帮忙这样做吗?
答案 0 :(得分:0)
Dim selectedItem As New Style(GetType(DataGridCell))
Dim triggerIsSelected As New Trigger() With {.[Property] = DataGridCell.IsSelectedProperty, .Value = True}
triggerIsSelected.Setters.Add(New Setter(DataGridCell.BackgroundProperty, System.Windows.Media.Color.Red))
selectedItem.Triggers.Add(triggerIsSelected)
Datagrid1.CellStyle = selectedItem