I have a popupMenuTool acting as a Context Menu that has a couple of nested popupMenuTools in it, one of the nested poup menus has a PopupControlContainer tool in it. I'm listening to an event on the embedded control and then closing the popupControlContainer, the problem is that the rest of the context menu does not close; this is inconsistent with what you'd expect from clicking on an option in a context menu.
Depending on what else happens on the event in the control the context menu will sometimes close (e.g. If I open a new dialog).
Is there a way to tell the whole context menu to close?
On the highest level PopupMenuTool, you can call ClosePopup(). You can call this on the root tool or any instance of the tool.
The problem I had with this approach is figuring out which is the 'root' popup. A lot of the context menus are created dynamically and I wanted a generic fix to this problem so I could say.
OnCloseRequested find root popup, and call ClosePopup() on it.
I couldn't figure out an easy way to do this as all the 'parent' or 'owner' properties seemed to be the root tools collection. The only way I could think of figuring out the root popup was to look through the root tools collection for popupMenus and recurse down through all the children till you found the right child. This seemed a bit overkill and it would probably just be easier to go through the root tools and call ClosePopup on any PopupMenus (but this seems a very brute force approach).
You can start with the instance of the tool which was clicked and recursively look up at the OwningMenu property. Once you get to a tool with a null OwningMenu, it is the highest level menu. You can also submit a feature request for the ability to close all open menus: http://devcenter.infragistics.com/Protected/RequestFeature.aspx.