Does anyone know how to access the data record (e.g. Business object) supplying a row in a XamDataGrid from a context menu on the grid?
Here's what I'm doing.
I am programatically adding a Context Menu to the Grid:
MenuItem sellItem = new MenuItem();
xamDataGrid1.ContextMenu.Items.Add(sellItem);
Then in the click event, I have tried numerous ways to access the data in the current row, one of those ways being the same way that other developers in our shop have accessed the data behind a row in the double click event. (see below)
(this works just fine):
DependencyObject source = e.OriginalSource as DependencyObject;
if (source != null){
CellValuePresenter cvp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(CellValuePresenter), true) as CellValuePresenter;
if (cvp != null){
someObject = ((<businessObject>)(((DataItemPresenter)(cvp)).Record.DataItem)).ProductKey;
...
}
Anyone got any ideas?
Thanks,
Damian