0

I have a standard MVVM app with a grid on my view. I'd like to add a dynamic context menu on each of the row (the menu items depend on row data) and bind some ICommand with them. To do so, I added the ContextMenuOpening event handler in the view code behind (xaml.cs). The problem is that command to which I'd like to bind the menu items are in the ViewModel. Is it possible to bind ContextMenuOpening to the VM?

View.xaml:

<UserControl x:Class="...."
....    
<dxg:GridControl ContextMenuOpening="ContextMenu_ContextMenuOpening" DataContextChanged="GridControl_DataContextChanged">
....
</UserControl>

I tired to add Binding to the ContextMenuOpening but then C# throw an error.

Comment: I know I can access the DataContext from the view code behind but I don't want to do this since this would bind me view with view model.

orwe
  • 233
  • 1
  • 3
  • 10
  • Check Mvvm Light, for example answer in this [question](http://stackoverflow.com/questions/5868589/mvvm-light-adding-eventtocommand-in-xaml-without-blend-easiery-way-or-snippet) – Anka Apr 21 '15 at 11:53
  • I can't use GalaSoft (it is not a bless lib in my company) ;/ – orwe Apr 21 '15 at 12:02

0 Answers0