I have a context menu on my XamDataGrid. I need to get the underlying row when I click on a context menu item for a selected row. For that I guess I would first need to set the row as selected on right clicking on a row. How do I achieve this?
SelectedDataItem of XamDataGrid does not have the values of the row selected. Any help on this pls
It’s not necessary to select the row that the content menu has been opened on to access the row of the XamDataGrid and apply some custom logic on it. In fact, a custom command could be used for the MenuItems of the ContextMenu, when the ContextMenu is set only for the rows of the XamDataGrid by applying the menu to the DataRecordCellArea. In the Execute method the command, the method parameter should be cast to DataRecordCellArea, from which the record could be obtained with the Record property. After the record is obtained you can apply any custom logic that fits the needs of your application.
I am attaching a small sample application that demonstrates what I have explained above.
Please test this sample on your side and let me know if you have any questions.