I have a button column with a click command that goes to this method. How do I find out which row/record it came from?
Private Sub OnContactInfoClick(ByVal sender As Object, ByVal e As Windows.RoutedEventArgs)
End Sub
Hello,
Sorry for not getting to this post in a timely manner. I hope this can still help. In situations like this where you only have the context of the button, you will have to crawl up the VisualTree to find the CellValuePresenter. From there, you can get the Record. Here is a code snippet.
DependencyObject dobj = e.OriginalSource as DependencyObject; while (dobj != null && dobj.GetType() != typeof(CellValuePresenter)) { dobj = VisualTreeHelper.GetParent(dobj);
} if (dobj != null) { CellValuePresenter cvp = dobj as CellValuePresenter; DataRecord dr = cvp.Record; }
I quickly put this together. You can also write recursive functions to handle this. I hope this helps.