SmartClient Factory: How to access the menu items?

T

tomromanul

Hi all,
I just started working with the SmartClient software factory and I ran
into a problem.

I create the menu from an XML file when the application starts, but I'd
like to alter it later on based on:
1. User actions (add some sub-menus dynamically, such as most recent
used files)
2. Availability of the connection to network (I'd like to
enable/disable some menu items)
I don't seem to find any recommendation regarding accessing the menu
after the application starts (at least in the samples and documentation
I've seen until now).
I can't find a way to access the menu items directly, unless I do it
directly in the Shell form. Any ideas? Please help.
Thanks, Tom.
 
B

Bryan Phillips

In the shell project, you need to call
RootWorkItem.UIExtensionSites.RegisterSite with a name and the menu:

RootWorkItem.UIExtensionSites.RegisterSite("MainMenu",
Me.Shell.MainMenuStrip)

This allows you to use the site like this in any loaded module:

RootWorkItem.UIExtensionSites("MainMenu")

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
 
T

tomromanul

Thanks, Bryan. Still doesn't work.

I can see that "MainMenu" is registered in ShellViewPresenter in the
Infrastructure.Layout project (created automatically by SCSF):


WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainMenu,
View.MainMenuStrip);

When I browse the root workitem I see a private object with this name
(under UIExtensionSites). However, when I do this:
RootWorkItem.UIExtensionSites["MainMenu"]
I get null (I'm using C#). I expected to get a UIExtensionSite object.

Strangely to me I can access the top level menus that I registered, for
example:
RootWorkItem.UIExtensionSites["MenuTools"]
returns a UIExtensionSite object. I say "strangely to me" because both
"MenuTools" and "MainMenu" are items of the same collection (I can see
them in QuickWatch)!

Now I ran into problem #2: I don't know how to use this UIExtensionSite
object. I cannot get access to its items (I can see the menu items I
added under that top level menu as private members in QuickWatch).

I checked once again the CAB reference, it's not very helpful. None of
the QuickStarts and hands-on labs I've seen show how to get from
UIExtensionSite to a contained menu item.

BTW, do you know of some sample code that would help me?

Thank you.
Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top