Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Selected row on right click context menu - XamDataGrid
posted

Hi,

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

Thanks,

Uma

  • 1320
    Offline posted

    Hello Uma,

    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.

    Regards,
    Ivan Kitanov



    AccessRowFromContextMenuItem.zip