I have datagrid. Each row is element of OBservableCollection declared in cs file. Each DataGridRow has the extra column with Delete button and click event.
How do I get the corresponding element of my OBservableCollection in button cl开发者_如何学Goick event function?
If you hook your button's click event, the sender should be button. The DataContext on that button should be the row item:
private void Button_Click(object sender, RoutedEventArgs e)
{
MyClass data = (sender as FrameworkElement).DataContext as MyClass;
}
精彩评论