开发者

WPF. Get clicked row item values

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜