This is more of a general WPF question than your controls, I tried posting on Expert Exchange and Stack Overflow without any success. So I thought you might be able to help.
n my app I have many grids (Infragistics). I would like to create a context menu that will implement many of the common functions ie: delete, save layout, etc. and if a specific grid needs more than the common functions be able to add to the menu for that grid. I would like to create one context menu and not have to repeat the same code throughout project.
I have no idea on how to accomplish this. Possible? Example xaml and/or code will be helpful.
Thanks a bunch,
Rick
Wow! Thank you for posting your solution!
Here is my solution I came up with:
I created a resource dictionary with code behind to hold my context menu (http://stackoverflow.com/questions/92100/is-it-possible-to-set-code-behind-a-resource-dictionary-in-wpf-for-event-handling):<
The following thread may also be of help to you:
http://forums.infragistics.com/forums/p/35591/207987.aspx
I believe the best approach to this would be to define one ContextMenu and assign it to the layout that contains all the instances of the XamDataGrid you wish to effect. This global contextual menu would change what it shows based on which element is clicked on. If you need to keep it from opening, you can override the Right Mouse Down event and control the opening of the ContextMenu programmatically.
Here are a couple of URLs to websites that show how to use the ContextMenu in such specialized ways:
http://www.wpftutorial.net/ContextMenu.html
http://stackoverflow.com/questions/2071932/how-to-add-condition-to-a-wpf-context-menu