使用UltraDockWorkspace的CAB

时间:2011-01-05 12:27:07

标签: c# infragistics cab

我正在为我的应用程序使用CAB和SCSF,我正在使用Infragistics的CAB可扩展性工具包

我遵循了这篇文章。样本有三个项目。壳牌形式。 common和SmartPartLib

Infragistics CAB Extensibility Kit

在SmartPartLib项目中有类ModuleController.cs。这个方法正在创建一些将在App开始时显示的视图...我想知道什么时候

this.WorkItem.Workspaces[Constants.WorkspaceNames.DockWorkspace]

已初始化。我试图在示例SCSF项目中做同样的事情,但我将此WorkspaceObject视为null ..请告诉我是否有人使用Infragistics CAB Kit ...

 private void AddViews()
        {
            //Create the Root View first, but do not show it
            RootView theRootView = this.WorkItem.SmartParts.AddNew<RootView>();


            //Here is the important part: 
            //Whenever dynamically creating controls that will interact with the
            //UltraDockManager, for the best results, make sure that you
            //assign a unique value to the control's "Name" property. In this case,
            //since the dynamic nature of CAB and SmartParts brings us to the
            //same situation, we also add a value to the SmartPart's "Name" property:

            TreeView theTreeView = this.WorkItem.SmartParts.AddNew<TreeView>();                 //1: Create
            theTreeView.Name = "theTreeView";                                                   //2: Set Name
            this.WorkItem.Workspaces[Constants.WorkspaceNames.DockWorkspace].Show(theTreeView); //3: Show it

            GridView theGridView = this.WorkItem.SmartParts.AddNew<GridView>();
            theGridView.Name = "theGridView";
            this.WorkItem.Workspaces[Constants.WorkspaceNames.DockWorkspace].Show(theGridView);

            ChartView theChartView = this.WorkItem.SmartParts.AddNew<ChartView>();
            theChartView.Name = "theChartView";
            this.WorkItem.Workspaces[Constants.WorkspaceNames.DockWorkspace].Show(theChartView);

            //Load the layout through the interface
            ((IRootView)theRootView).LoadDockLayout();

            //Finally show the Root View
            this.WorkItem.Workspaces[Constants.WorkspaceNames.MainWorkspace].Show(theRootView);

        }

1 个答案:

答案 0 :(得分:0)

您可以尝试实现IBuilderAware接口,并从OnBuiltUp方法调用AddViews方法。初始化Workspace集合后,CAB将调用此方法。