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
225
ListToolItem right-click context menu
posted

I have an Office 2010 style ribbon. The application menu has a PopUpMenuTool with a ListTool on it (like the MRU list example). I'm trying to figure out how I can trap a right-click event on a ListToolItem so that I can display a custom context menu. Basically, I'm trying to emulate the behavior of MS Word 2013's "recent" document list where you can right-click on a document in the MRU list and see a menu of options.

Any suggestions?

MS Word MRU

Parents
  • 6158
    Offline posted

    Hello.

    I'm pretty sure we can get this functionality working. Start off by setting the UltraToolbarsManager.Ribbon.ApplicationMenu2010.ShowDefaultContextMenu to True. This will allow the BeforeToolbarListDropdown event to fire when you right-click on a tool in the ApplicationMenu2010. Next, we will need to handle the event and see if we can get a ListToolItem from the context of the tool's UIElement:

            private void ultraToolbarsManager1_BeforeToolbarListDropdown(object sender, Infragistics.Win.UltraWinToolbars.BeforeToolbarListDropdownEventArgs e)
            {
                if (this.ultraToolbarsManager1.Ribbon.ApplicationMenu2010.IsOpen)
                {
                    // cancel the event, as we really don't want to show the default context menu.
                    e.Cancel = true;
                    UIElement element = e.Tool.UIElement;
                    if (element != null)
                    {
                        ListToolItem item = element.GetContext(typeof(ListToolItem)) as ListToolItem;
                        if (item != null)
                        {
                            // show custom context menu
                        }
                    }
                }
            }

    Now just fill in the section with  '// show custom context menu' comment with a call to display your own custom menu. Let me know if you have any questions. Chris

Reply Children
No Data