Unlike a traditional context menu, with a Krypton context menu you do not add standard menu options to the top level of the control. Instead the top level collection can only contain either a heading, an item collection or a separator. The item collection contains the actual set of individual menu options.

So why does Krypton use a separate child collection for the actual menu options?

The advantage is that you can then alter the ItemStyle, ImageColumn and other properties for just that individual collection of options. Here you can see an example of this in action…

 

The top level looks like the following…

   <Heading Item>
   <Item Collection>
   <Separator Item>
   <Heading Item>
   <Item Collection>

The first item collection contains the Cut, Copy, Paste etc set of options. It also contains a vertical separator so that the items are split over two columns. Notice that this does not force two columns for the whole context menu, only for the items collection they are inside. After the second heading there is another item collection that has the three server related menu options. In this collection the ItemStyle has been defined as Alternate and ImageColumn turned off.

An item collection can contain not just menu options but also separators and headings.

Here is the same menu using the system palette…

3 Responses to “Mixing Collections”

  1. Darkas Says:

    This is cool. I’d like to this in the next time in my app.

  2. Michael Rawi Says:

    On Edit Option menus, If I highlight Undo or Redo, a new context menu will show correct? Then what if you place Undo or Redo in left vertical separator while others are in right one? If you still showing a new context menu then user won’t be able to see anything in right context menu…

    Just some idea, maybe you can use a transparent like VS2008 new intellisense (pressing ctrl while it show will make it transparent)..

  3. Phil Wright Says:

    A good point.

    I will show the sub menu to the immediate right of the menu item that is selected. So yes it will obscure the ‘Undo,Redo,Clear Undo’ part of the context menu.

    The solution for the user is to press the ESCAPE key or LEFT ARROW key to dismiss the newly showing sub menu to go back to the starting context menu. Alternatively move the mouse over another part of the original menu in which case the sub menu will also be dismissed.

    In practive you have to decide if this functionality is appropriate for your scenario. If your customers complain that it is a problem then only use menu items without a sub menu in the first column. Or just don’t use multiple columns at all!

    By the way, standard context menus allow vertical breaks and so has exactly the same issue if you decided to create multiple columns.

Leave a Reply