2011-01-05 17 views
0

我使用CAB和SCSF我的申請,我使用CAB擴展工具包從Infragistics的CAB與UltraDockWorkspace

我跟着這篇文章。該示例有三個項目。殼牌形式。常見SmartPartLib

Infragistics CAB Extensibility Kit

在SmartPartLib項目有類ModuleController.cs。此方法正在創建一些視圖,這些視圖將顯示在App開始...我想知道,當時

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

已初始化。我試圖做同樣的樣品SCSF項目,但我得到這個WorkspaceObject爲空。請告訴我是誰用的Infragistics CAB包...

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); 

     } 

回答

0

您可以嘗試實現IBuilderAware接口,並打電話給你AddViews方法從OnBuiltUp方法。 CAB在Workspace集合初始化後的某一點將調用此方法。

+0

問題是什麼時候Workspace集合被初始化。在Microsoft提供的示例中,他們正在ShellForm.cs類中註冊工作區 – Mohsan 2011-01-06 05:33:35