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
XamDataGrid ContextMenu Handler in MVVM

Hi, I have been struggling for a few days now to find an answer for these questions.

first, I need to a be able to select an item on right click on the XamDataGrid. I did hope that my XAML

for ContextMenu would do the trick and I saw that the item that is highlighted when I right click on the

row to get the ContextMenu I open, would set the SelectedItems property, but the bound property in

my ViewModel returns a null on this.


Next, I am trying to pass the Row on the XamDataGrid as the item to my ContextMenu (Command)

handler in my ViewModel which relates  to my effort on the previous point. I read numerous posts

about ContextMenu being not on the same Visual tree as the XamDataGrid itself, which is why the

property SelectedItems cannot be propogated to the Command. I even read that the SelectedItems

property on XamDataGrid is not aDependencyProperty which is why even upon binding it to a property

defined in the ViewModel, it wouldn't stick to it.


My goal is to pass the row values or the entire row of the XamDataGrid, when I right click on ContextMenu

to perform some action which needs these details in the CommandHandler in the ViewModel. How

can I achieve this?


I posted the code and my question even on stackoverflow here

.  Any help is very much appreciated.