I am creating a menu that will have its menu items injected into it from different modules (I am using the Composite Application Library: Unity, Prism).
Example:
File - Open - New - A (injected from ModuleA) - B (injected from ModuleB) - C (injected from ModuleC) - Exit
Because I don't know which items will be injected, I need to somehow sort my Menu Items. I am trying to do this now by creating a RankedMenuItem that inherits from MenuItem. RankedMenuItem has one additional property, Rank, which is an integer.
I set the "File -> Exit" menu item to be rank 1000, and "File -> Open" to be rank 0, so that Exit will always show up at the bottom of the File menu, and Open will always show up at the top.
The trouble I'm having is that I can't figure out the best way to sort the menu hierarchy. I can sort the top level easily using a CollectionView, but I can't figure out how to apply it to the subitems.
Any advice would be much appreciated.