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
960
Adding XamMenuItems to existing XamContextMenu
posted

Hi, as I said in the subject, I have a User control with a XamDataTree that has a XamContextMenu

This user control will be used in different contexts and based on where I use it I need to add some XamMenuItems to the tree context menu.

I've seen on a previous message on the forums how to create the context menu at runtime, but my context menu already contains a number of elements

I just need to retrieve it when I've initialized the control and add some local commands.

For example, on my Context Menu I already have a New, Delete, Cut, Copy, Paste menu item I need to add some specific commands like "Execute my Procedure 1" and more.

The thing I can't find is How to Get the Context Menu from the XamDataTree, there is a ContextMenu property, but it is null,

so I presume there is something different to do to retrieve the Context Menu.

Parents
  • 34850
    Offline posted

    Hello Sabrina,

    Thank you for your post.

    When using a XamContextMenu on the XamDataTree, you need to set it on the ContextMenuManager, and so it does not really reside in the XamDataTree's ContextMenu property. To get this manager, I would recommend using Infragistics.Controls.Menus.ContextMenuService.GetManager(tree); This will get you the context menu manager, and from it, you can get the XamContextMenu from manager.ContextMenu. The reason I included the full name of the ContextMenuService is because there is some ambiguity between the Infragistics version and the System.Windows.Controls version.

    I have attached a sample application to demonstrate the above.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamDataTreeContextMenuRetrievalCase.zip
Reply Children