in my DataGrid the last column is a TemplateColumn that has an Edit Button, the current implementation is that the user needs to check a checkbox beside the row and then click the edit button, obviously, this is nonsense, so isn't there a way to get the current row when I click the related edit button?
The "current row" is the DataContext of the Button so you could cast the sender argument and the DataContext property:
private void Button_Click(object sender, RoutedEventArgs e)
{
Button button = sender as Button:
YourClass selectedRow = button.DataContext as YourClass;
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With