请问WPF DataGrid SelectionChanged事件中怎么获取行啊?dataGridRow.Background好像只有获取行后才设置
1个回答
展开全部
datagridrow.background不需要获取行后才能设置的,比如你在trigger设置。
<>operty="IsMouseOver" Value="True">kground" Value="Yellow"/>ü斋electionChanged获取datagridrow对象可以这么写(dg为DataGrid名阊≈械氖堤宥韵螅?
privactionChanged(object sender,tionChangedEventArgs e)
{
TestDemo t = dg.SelectedItem as TestDemo;
if (t != null)
{
DataGridRow dr = (DataGridRow)(dg.ItemContainerGenerator.ContainerFromItem(t));
dr.Background = new SolidColorBrush(Colors.Yellow);
}
}
<>operty="IsMouseOver" Value="True">kground" Value="Yellow"/>ü斋electionChanged获取datagridrow对象可以这么写(dg为DataGrid名阊≈械氖堤宥韵螅?
privactionChanged(object sender,tionChangedEventArgs e)
{
TestDemo t = dg.SelectedItem as TestDemo;
if (t != null)
{
DataGridRow dr = (DataGridRow)(dg.ItemContainerGenerator.ContainerFromItem(t));
dr.Background = new SolidColorBrush(Colors.Yellow);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询