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
50
Pass current row element to context menu
posted

I need to pass current to the context menu command. Here is my xaml code:

                            <igDP:XamDataGrid.ContextMenu>
                                <ContextMenu>
                                    <MenuItem
                                        Header="{x:Static r:Resource.Cancel}"
                                        Command="{Binding Path=CancelCommand, Mode=OneWay}"
                                        CommandParameter="{Binding Path=PlacementTarget, RelativeSource={RelativeSource self}}" />
                                </ContextMenu>
                            </igDP:XamDataGrid.ContextMenu>

And here is the C# code in my ViewModel:

        private void Cancel(object obj)
        {

        }

        private bool CanCancel(object obj)
        {
        }

What should I write in "CommandParameter=" so that I get a reference to current row item or at least it's number? I was trying many different options, but in most cases I get null. In some cases I was able to get a reference to the ViewModel, to the context menu, or to the grid, but this does not do any good since I can get reference to it anyway.

Parents Reply Children
No Data