I would like to have global Context Menu that can be used in all datagrids. I defined ContextMenu and style in App.xaml. Main Window is build with many UserControl.
<Application.Resources>
<ContextMenu x:Key="contextCommonMenu">
<MenuItem Header="Import from Excel" Command={???} />
<MenuItem Header="Export table to .csv file"/>
<MenuItem Header="Save to Database"/>
<MenuItem Header="Clear Data" />
<MenuItem Header="Synchronize with DB"/>
</ContextMenu>
<Style TargetType="DataGrid">
<Setter Property="ContextMenu" Value="{StaticResource contextCommonMenu}"/>
</Style>
</Application.Resources>
My problem is how can I bind a command from ViewModel to ContextMenu ?
If the ContextMenu was created in UI Control, then it is simple, because Binding see the ViewModel but I do not have access to ViewModel?