UIExtensionSites.RegisterSite problem

Topics: CAB & Smart Client Software Factory
Nov 30, 2006 at 9:30 AM
originally posted by: alexsantos

Hi,

I have a MDI application, so for each Window I create a toolbar and uses RegisterSite for it...like :

WorkItem.UIExtensionSites.RegisterSite("WinToolBar",this.WinMenuStrip);

My customer can open many MDIs about same information. Each MDI has own WorkItem.

The problem is even using a WorkItem for each MDI I can't register UIExtension with same names...remember ! Same names but different WorkItem...

My question is : UIExtensionSites is global ? How to register an UIExtensionSites only for that WorkItem ?

Thanks,
Alexnaldo Santos
Nov 30, 2006 at 11:35 AM
originally posted by: Tex47

Hi,

UIExtensionSites are bound to the current WorkItem where they will be registered. To make those global, u have to use the RootWorkItem.
Sample

class SmartPartApplication : FormShellApplication<WorkItem, MainForm>
{
...

protected override void AfterShellCreated()
{
base.AfterShellCreated();
RootWorkItem.UIExtensionSites.RegisterSite("MainMenu", this.Shell.MainMenuStrip);
}


Hmm, to register those UIExtensionsSites for a special WorkItem, you have to find this special WorkItem from the Items list and than register the controls.
To find this specific Workitem, u have to register this WorkItem at the RootWorkItem and just find it by its ID, otherwise, u have to use a recursive search from the RootWorkItem -> ModuleWorkItem -> your Special Workitem for the Form, which requires, that tis WorkItem has been instanced. You could also use the ModuleWorkItem for registering, that make it local to the module, and the ModuleWorkItem would be the Parent of the MDI WorkItem.

Greetz
Kristian