Add UIElements from Multiple Modules?

Topics: CAB & Smart Client Software Factory
Sep 12, 2008 at 10:09 AM
Hi,

I want to add ToolBar menu items to a single top menu item on the menu bar in the shell layout.

I mean I add a new toolbarmenuitem to the UIExtensionSite representing the main menu toolbar in the shell from the first workitem. this is a menu item sitting next to 'File' for example, so call it 'Work'. 

    UIExtensionSite menu= WorkItem.UIExtensionSites["MainMenu"];
    ToolBarMenuItem work = new ToolBarMenuItem("Work");
    work.Add.DropDownItems(new ToolBarMenuItem("When Not Sleeping");
    menu.Add(work);

Then in the subsequently loaded workitems, I want to add additional toolbar menu items underneath that same top level menu item

    work.Add.DropDownItems(new ToolBarMenuItem("Before Bills Due");

But I would expect to somehow be able to get a reference to the 'Work' menu item on the main menu bar.

If I were to call WorkItem.UIExtensionSites["MainMenu"].Contains(work); again, I need a reference to the original work toolbar menu item created in the previous work item.

How can this be done?

Thanks,

Kimball
Sep 12, 2008 at 6:31 PM

Hi,

 

You cannot retrieve the menu from its UIExtensionSite wrapper. The UIExtensionSite class hides the concrete type of the underlying UIElement, but exposes the type that its collection accepts. For this purpose, it provides a generic interface with the methods Add(uiElement) and Remove(uiElement). If you were to expose the concrete, underlying UIElement, you could do it by creating a new class which inherits from UIElementAdapter<TType> (TType should be the type of the items that the collection would accept) and provide a property (or method) that retrieves the UIElement. However, this would go against the purpose of the UIExtensionSite class.

 

Perhaps, you should consider adding the menu item to the Items collection of the RootWorkItem and then retrieve it via this collection. I.e.:

//When registering the MainMenu

WorkItem.RootWorkItem.Items.Add(menu, "MainMenu");

 

//registering if you have the RootWorkItem

RootWorkItem.Items.Add(menu, "MainMenu");

 

//When retrieving the MainMenu

ToolStripMenuItem menu = WorkItem.RootWorkItem.Items.Get<ToolStripMenuItem>("MainMenu");

 

You may find useful the following blog posts:

·         Introduction to UIExtensionSites (Introduction to the CAB/SCSF Part 13)

·         More on UIExtensionSites (Introduction to CAB/SCSF Part 14)

 

Please, let me know if this helps.

 

Ignacio Baumann Fonay

http://blogs.southworks.net/ibaumann/

Sep 12, 2008 at 6:36 PM

Ignacio,

It is a pleasure to hear from you. I have enjoyed reading your many informative comments.

In fact, your suggestion was what I did.

In addition, I discovered the generic methods that you refer to and was pleased to find that they were available in all the necessary places to complete a type-based process.

I will look into those articles.

Thanks very much,

Kimball Johnson

From: ibaumann [mailto:notifications@codeplex.com]
Sent: Friday, September 12, 2008 11:32 AM
To: Kimball Johnson
Subject: Re: Add UIElements from Multiple Modules? [smartclient:35522]

From: ibaumann

Hi,

You cannot retrieve the menu from its UIExtensionSite wrapper. The UIExtensionSite class hides the concrete type of the underlying UIElement, but exposes the type that its collection accepts. For this purpose, it provides a generic interface with the methods Add(uiElement) and Remove(uiElement). If you were to expose the concrete, underlying UIElement, you could do it by creating a new class which inherits from UIElementAdapter (TType should be the type of the items that the collection would accept) and provide a property (or method) that retrieves the UIElement. However, this would go against the purpose of the UIExtensionSite class.

Perhaps, you should consider adding the menu item to the Items collection of the RootWorkItem and then retrieve it via this collection. I.e.:

//When registering the MainMenu

WorkItem.RootWorkItem.Items.Add(menu, "MainMenu");

//registering if you have the RootWorkItem

RootWorkItem.Items.Add(menu, "MainMenu");

//When retrieving the MainMenu

ToolStripMenuItem menu = WorkItem.RootWorkItem.Items.Get<ToolStripMenuItem>("MainMenu");

You may find useful the following blog posts:

· Introduction to UIExtensionSites (Introduction to the CAB/SCSF Part 13)

· More on UIExtensionSites (Introduction to CAB/SCSF Part 14)

Please, let me know if this helps.

Ignacio Baumann Fonay

http://blogs.southworks.net/ibaumann/

Read the full discussion online.

To add a post to this discussion, reply to this email (smartclient@discussions.codeplex.com)

To start a new discussion for this project, email smartclient@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com



This message is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you have received it by mistake, please let us know by e-mail reply and delete it from your system; you may not copy this message or disclose its contents to anyone. Please send us by fax any message containing deadlines as incoming e-mails are not screened for response deadlines. The integrity and security of this message cannot be guaranteed on the Internet.
Oct 29, 2010 at 10:59 AM
Edited Oct 29, 2010 at 11:01 AM

Its a great read.. I improved a lot by this discussion. thanks for the discussion.

chicago escort

chicago female escorts

Jul 7, 2011 at 3:42 PM
Edited Jul 7, 2011 at 3:46 PM

I don't know how to delete

Dec 19, 2013 at 4:47 AM
WorkItem.RootWorkItem.Items.Add(menu, "MainMenu");

#00B050">//registering if you have the RootWorkItem

RootWorkItem.Items.Add(menu, "MainMenu");

#00B050">//When retrieving the MainMenu

#4BACC6">ToolStripMenuItem menu = WorkItem.RootWorkItem.Items.Get<#4BACC6">ToolStripMenuItem>("MainMenu");
Thanks for the heads up. That's where I got lost. It's great knowing Chicago Escorts.