<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"MouseRightButtonDown"
>
<
mvvmcmd:EventToCommand
Command
=
"{Binding ItemClickedCommand}"
CommandParameter
=
"{Binding CurrentCell, ElementName=ContractProxyDataGrid}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
I'm trying to do a similar thing with my RadGridView but binding to CurrentCell gives me a null parameter. What I am trying to get at is the DataGridCellInfo (or something similar) of the cell that was right clicked. What should I be binding too?
Thanks.
9 Answers, 1 is accepted
That would be the expected behavior since MouseRightButtonDown does not cause any cell to be set as current. What is the exact behavior that you want to get ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Generally, it is not recommended to work with visual elements in your ViewModel. Still, if you need to have the cell you right-clicked on, you can pass the arguments of the event to the command and work with them in the view model:
<
cmd:EventToCommand
PassEventArgsToCommand
=
"True"
/>
Kind regards,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Essentially what I'm trying to do is, when a cell is right-clicked I need to get the name of the column in which that cell is and what "row" or "item" it is a part of. Any ideas?
Thanks.
You can get the the OriginalSource from the arguments and using ParentOfType<T>() extension method to find parent cell and parent row. Still, I will recommend you to consider your architecture so that you do not work with visual elements in your ViewModel.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Thanks
My recommendation would be to handle directly the event and update the architecture so that you do not need to work with visual elements in your ViewModel. If you do not want to have code in the YourPage.xaml.cs file, you can try creating an attached behavior instead and handle the event there.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

You need to find the parent row and set it as selected.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.