Hi, I have a question about the Context Menu.
I have a window with a XamMenu inside, and coming from Windows Forms I usually create a Context Menu indicating which menu item of the Toolbars Manager to use on each control in the window.
Now looking at the WPF version of the Context menu it seems that I have to rewrite a new Context menu...
It is not a problem, I just wanted to know
a) Is this correct? Do I have to define the whole ContextMenuService, ContextMenuManager, etc. for each control with a context menu.
b) If I have two different menus for two different controls is there any problem with using two different Context Menus?
c) If I have two controls in different positions on the window and want to give them the same context menu, do I have to duplicate it for each control or can I define it once and assign to more controls? (given that the controls are not in a common container so I cannot put the menu in the container)
The samples on the samples browser show all just one context menu on a single control, so this is not clear.
Hello Sabrina,
Thank you for your post!
A. If you are using the XamContextMenu, then yes, I believe you need to define the ContextMenuService.Manager for each control you wish to place the context menu on. Most controls have a context menu property that you can use though, and you can place the built in WPF context menu there if you wish to use that. You do not need to rebuild the context menu to reuse it though, I will describe this in point C.
B. I see no issues with using two different context menus for two different controls.
C. If you wish to use the same context menu for different controls on different positions on a window, I would recommend placing a x:Key on a XamContextMenu in the resources of the window or other containing element. You can build your context menu there. Then, when you go to use it, you can place it on the ContextMenuManager's ContextMenu property as a resource.
I have attached a sample application demonstrating the reuse of a XamContextMenu in a WPF application.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Just checking in, did you have any other questions or concerns on this matter?