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
1590
Different context menus in the same xamDataGrid
posted

Hi,

I have a xamDataGrid in which I show master/detail data to the user. When the user right clicks the grid, the user should have some context menu options. However, the exact options depend on where the user clicks. There are 3 possibilities. Either the user clicks (1) a header row, (2) a detail row, or (3) the empty grid area (where there aren't any rows). Also, these 3 possibilities execute a different command on the viewmodel, and when the user clicks either a header or detail row, the menu items should pass the clicked row's data item as command parameter.

I was already able to accomplish this functionality using classic WPF context menus, but now we want to use the IG context menu so it all blends in the same theme style. But I can't get it working using IG controls. In the old situation I set 1 context menu on the grid itself, and another on a Style for DataRecordCellArea (actually, that one would determine the type of data in the row and choose between one of 2 context menus that were defined as resource).

I've been searching for a solution using IG controls, and I already read this post:

http://ko.infragistics.com/community/forums/t/58709.aspx 

And even though maybe I could solve it using the ContextMenu events, I would prefer not using any code-behind. I didn't need code behind before either. So, is there a pure XAML way of solving this?

If I'm not clear enough in my description, please just say so and I will elaborate.

Regards, Stefan

Parents
  • 30945
    Offline posted

    Hello Stefan,

     

    Thank you for your post. I have been looking into the description of the functionality that you are trying to achieve and what I can suggeest is using the appraoch that you have described, with one menu for the XamDataGrid and using a style for the DataRecordCellArea, to set the ContextMenuService.Manager, to different menu, based on whether the Record of the DataRecordCellArea has a parent. The sample is using only bindings to implement the functionality that you are looking for.

     

    Please let me know if you need any further assistance on the matter.

    Sincerely,

    Krasimir, MCPD

    Developer Support Supervisor - XAML

    Infragistics

    www.infragistics.com/support

    DiffernetXamContextMenuBasesOnClickedItem.zip
Reply Children