SCSF:显示从另一个视图按下按钮点击的视图

问题描述:

我在SCSF面临一个问题。SCSF:显示从另一个视图按下按钮点击的视图

我有两个工作区

  1. MdiWorkspace
  2. DeckWorkspace

我有一个模块中的两个视图

  1. 查看器(在mdiworkspace显示)
  2. 属性查看器(在deckworkspace)

在Viewer中,我在工具栏上有一个按钮,其目的是显示PropertyViewer(另一个视图)。

我该如何在deckworkspace agaist按钮单击事件中显示此PropertyViewer。

注意:我不使用命令[的CommandName] .AddInvoker(控制,“点击:)和CommandHandler

我会假设你的工具栏位于在实现MVP模式的的SmartPart有SmartPart中的按钮点击事件处理程序会触发其演示者将处理的事件。您的演示者代码如下所示:

 
// Presenter code 

protected override void OnViewSet() 
{ 
    this.View.ToolbarButtonClick += View_ToolbarButtonClick; 
} 

public void View_ToolbarButtonClick(object sender, EventArgs e) 
{ 
    // remove the handler so the property viewer 
    // will only be added the first time 
    this.View.OnToolbarButtonClick -= View_ToolbarButtonClick; 

    var propertyView = new PropertyViewer(); 
    this.WorkItem.Workspaces[WorkspaceNames.MyDeckWorkspace].Show(propertyView); 
}