This project is read-only.

Creating submenus, etc.

May 22, 2013 at 1:06 AM

I can create a menu (and now a toolbar, thank you) using the battleship theme.

Let's say I have the following:
Actions.Add(new ViewAction("Open", category: "File", execute: (a, o) => Controller.Message("Open clicked!"), significance: ViewActionSignificance.AboveNormal, categoryOrder: 0));
Actions.Add(new ViewAction("Close", category: "File", execute: (a, o) => Controller.Message("Close clicked!")));
Actions.Add(new ViewAction("Exit", category: "File", execute: (a, o) => Controller.Message("Exit clicked!")));
And now I want to have a submenu under close with the following options:
close current
close all

I know this is simplistic, but you get the idea.

I am guessing that to do so, I only need to do something with the category value, but not sure what I would do with it so that these appear as a submenu.

I am guessing it's in the style, but am still learning how to interpret those....

Also, if I set an action to have the highestSignificance (so it is included in the toolbar), how will that affect the position/implementation in the menu (if at all)?


May 24, 2013 at 6:36 AM
Well, the short answer is that you do it by setting multiple categories. Here's an example:
 var readyAction = new ViewAction("Set Ready Status", category: "Status", execute: (a, o) => Controller.Status("Ready."));
 readyAction.Categories.Add(new ViewActionCategory("OneMore", "One More Level"));
So in this case, there is supposed to be a "Status" to level menu in the menu bar, and then under it, there is supposed to be a "One More Level" menu item, and if you click that, up pops the actual "Set Ready Status" menu item, which can be clicked to trigger the action.

I am saying "supposed", because I just discovered that a bug must have snuck in and this wasn't currently working right. I fixed the bug in our internal build already, and a fix will be in the next build, which is due soon. (If you need it super-urgently, I can get you an internal build).

Jun 25, 2013 at 12:27 AM

Ok, new build installed and running (thank you!) But I can't get the submenus to work (well, I can get your example, but not something that does more than show an option). I have tried a few variations and found modest success, but nothing that really works as desired.

Assuming I want a view menu with a themes submenu that will allow me to select a desired theme, I get partial success with:
Actions.Add(new ViewAction("View Item1", category: "View", execute: (a, o) => Controller.Message("View Item1 clicked!")));

var xx1 = new SwitchThemeViewAction("Battleship", "Windows 95 Theme", category: "View");
xx1.Categories.Add(new ViewActionCategory("Themes"));

var xx2 = new SwitchThemeViewAction("Workplace", "Workplace (Office 2013) Theme", category: "View");
xx2.Categories.Add(new ViewActionCategory("Themes"));

I know I am missing something really obvious about how these all fit together.

The idea is to have a menu like this:
view item 1
view item 2
themes > Workplace

Jun 25, 2013 at 10:28 PM
This seems to work for me. For a test, I have changed the default first theme action in StartViewModel to this:
var a1 = new SwitchThemeViewAction("Workplace", "Workplace (Office 2013) Theme", category: "View", categoryAccessKey: 'V', accessKey: 'W');
a1.Categories.Add(new ViewActionCategory("Themes"));
As a result, I get this:


Jun 28, 2013 at 8:28 PM
Edited Jun 28, 2013 at 8:29 PM

Given the following code, I get the results shown below:


You may note that the 1st theme reference works as desired, but the next two show up in both places:
Actions.Add(new ViewAction("Module Records Toolbar", category: "View", execute: (a, o) => Controller.Message("Module Records Toolbar clicked!"), categoryOrder: 2));
Actions.Add(new ViewAction("Query Toolbar", category: "View", execute: (a, o) => Controller.Message("Query Toolbar clicked!")));

var a1 = new SwitchThemeViewAction("Workplace", "Workplace (Office 2013) Theme_", category: "View", categoryAccessKey: 'V', accessKey: 'W');
a1.Categories.Add(new ViewActionCategory("Themes"));
a1.CategoryOrder = 40;
a1.GroupTitle = "myThemes";

var a2 = new SwitchThemeViewAction("Battleship", "Windows 95 Theme_", category: "View", categoryAccessKey: 'V', accessKey: '9');
a2.Categories.Add(new ViewActionCategory("Themes"));
a2.CategoryOrder = 41;

var a3 = new SwitchThemeViewAction("Geek", "Geek Theme_", category: "View", categoryAccessKey: 'V', accessKey: 'G');
a3.Categories.Add(new ViewActionCategory("Themes"));
a3.CategoryOrder = 42;
Again, I am sure it's really simple, but I am not sure what to do to fix it.


Jul 1, 2013 at 9:36 PM
Hmmm.... could be a bug. Let me check that out.

Mar 22, 2017 at 12:26 AM

I know this is years later so just wondering if someone has found a solution to this?

Mar 27, 2017 at 5:59 PM

I'm finding this framework really productive and I am currently carrying out a PoC to see if we could use this for internal LoB applications.

Unfortunately I am also struggling with the ability to create sub-menus to contain more than one item and this could be a deal breaker, which would be a great pity with the amount of work that has been done to create this framework. I was looking in the ViewActionCategory object model thinking I would find an actions collection within it that would take those sub-items within its scope.

It would be great if this could be resolved.