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
1770
xamDataGrid Context Menu null items passed
posted

Hello. This is what I have:

<igWPF:XamDataGrid DataSource="{Binding MainLogDataGrid}" >
<igWPF:XamDataGrid.Resources>
<ContextMenu x:Key="RecordContextMenu">
<MenuItem Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igWPF:XamDataGrid}}, Path=DataContext.InsertCommand}" Header="Open" />
</ContextMenu>
<Style TargetType="{x:Type igWPF:CellValuePresenter}">
<Setter Property="ContextMenu" Value="{DynamicResource RecordContextMenu}"></Setter>
</Style>
</igWPF:XamDataGrid.Resources>
</igWPF:XamDataGrid>

In my main view model class:

public RelayCommand<object> InsertCommand {get; private set;}

public MainViewModel(){InsertCommand = new RelayCommand<object>(OnButtonPressMethod);}

public void OnButtonPressMethod(object menuItem)
{
var item = menuItem as MenuItem;
}

menuItem parameter in OnButtonPressMethod is null when I select whatever is in the context menu. I do have some dummy data in my xamDataGrid. Thanks