I am attempting to migrate from Infragistics v7,3 to v16.2.
So far this has been mostly painless, however for some reason the existing code which dynamically changes the context menu based on data that is present in the row you are right clicking on, is no longer working as expected.
I have verified that our 'mergeMenus' method is in fact adding the 'sourceMenu' items to the 'targetMenu':
public static void MergeMenus(PopupMenuTool targetMenu, PopupMenuTool sourceMenu) { if (targetMenu != null && sourceMenu != null) { //Add source tools into target menu... int count = 0; ToolBase addedTool; foreach (ToolBase tool in sourceMenu.Tools) { if ( !targetMenu.Tools.Exists(tool.Key) ) { addedTool = targetMenu.Tools.AddTool(tool.Key); addedTool.InstanceProps.IsFirstInGroup = tool.InstanceProps.IsFirstInGroup; count++; } } //Group merged source items... if (count > 0) targetMenu.Tools[targetMenu.Tools.Count - count].InstanceProps.IsFirstInGroup = true; } }
All the tools are present in the targetMenu (though they are not visible on screen) and have all properties set exactly the same as those tools who are visible except:
AttachedParentTool is null and UIElement is null. Unfortunately these are read only properties and I cannot find any documentation on how these values should be properly initialized. I'm not even sure if this is causing the problem or not. Am I missing something?
So, I am one step closer with this reply, thank you Mike. I have added MergeType = Replace and MergeOrder = 999 (so that whenever I add/remove a tool it is added to the bottom, this is what I want so not necessarily a 'universal' fix for anyone else reading this). I also had to add: myToolmanager.MdiParentManager.RefreshMerge(); wherever I am pro grammatically altering the menu, otherwise the changes are not reflected on Screen.
Now I have an issue where other submenu popups coming off the main context menu are appearing in odd locations, but this is most likely an artifact of my changes since other menus that don't dynamically change show their submenus correctly.
When the menus are merged between the Mdi Parent and Mdi child, the merge behavior and order of the tools is determined by the MergeOrder and MergeType properties. Frankly, I'm not an expert on tool merging. It's quite complicated.
I will see if this is feasible (this would take a lot of time). In the meantime, can you think of a reason why a PopupMenuTool is displaying tools out of order? The items in the Tools collection are in the correct order, what is displayed on screen is in a different order. I used arrays of tools in the correct order and the used Tools.AddRange to build up a Tools collection that is in the order I want but what is displayed is incorrect.
If you cannot reproduce the problem by starting a new project and building up from there, perhaps you could try the other way - make a copy of your real application and then reduce it down to something that just reproduces the issue.
After building a very stripped down version, I cannot reproduce this problem. So there must be some interaction between the various layers of inheritance + event handlers that works fine in v7.3 but causes issues in v16.2. The project is proprietary and large so posting it is not an option.