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?
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:
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
So I thought it was working... but the UIElement I get back from e.Tool.UIElement is always the first ListToolItem in my MRU list and not the one that was right-clicked. How do I get the UIElement of the ListToolItem that was actually right-clicked?
Hello,
you should modify the suggested code like:
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)
var point = element.Control.PointToClient(e.ScreenPoint);
var rightClickeDtEl = element.ControlElement.ElementFromPoint(point);
ListToolItem item = rightClickeDtEl.GetContext(typeof(ListToolItem)) as ListToolItem;
if (item != null)
// show custom context menu
}