I have a data grid in my wpf application. I wants that when user clicks on any button in the datagrid the corresponding row should be red. I think we can do it by using event trigger but i really don't know how to use it.
<DataGrid x:Name="dgEmp" Grid.Row="1" AutoGenerateColumns="False" CanUserAddRows="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Width="*" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="Age" Width="*" Binding="{Binding Path=Age}"></DataGridTextColumn>
<DataGridTemplateColumn Header="Delete" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Delete selected row"></Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
You can set up a colour property in each row, bind this to the rows background colour and change it as the SelectedItem changes.