Change datagrid selected row color programatically using wpf?
I want to change the selected row color dynamically开发者_如何学Go in code behind. I'm using Visual Studio 2008. Can anyone help to do this?
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
精彩评论