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
Hi Krasimir,
Can you please let me know how different context menu can be done on Infragistics version 10.3?
Also I want the menu to be shown only on the third level of hierarchy in the grid?
Regards,
Sabarish
Hello Stefan,
Thank you for your reply. I am very glad that the approach I have suggested was helpful for you. Please let me know if you need any further questions on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Excellent! Good job!
Thank you for your reply. I have been looking into the issue with the DataContext of the menu items and I can suggest changing the binding for the DataContext to MultiBinding and bind to the XamContextMenu itself and also for the IsOpen property of the XamContextMenu. By doing so, when the context menu is opened, the binding will trigger and you will be able to get the DataRecordCellArea for the child records and also to update the parameter for both parent and child records. I have modified the sample application that you have attached to show how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Thanks for your solution. It works, so I could use it as a solution. However, I was trying to alter your sample so that I wouldn't need any viewmodels for the menu items, because this would save me a lot of time refactoring my viewmodels. I was trying to bind the context menu items to new commands in the MainViewModel, but I can't get them all working correctly.
Could you please take a look at it? I've posted your sample with altered code.