2012-07-31 100 views

回答

1

我相信這是一個方便的問題。我們在色帶使用的命令爲按鈕:

Public Sub AddElementToRibbonGroup(WorkItem As WorkItem, elementDescription As String, menuGroupKey As String, commandName As String, commandKey As String) 
    WorkItemController.ShellExtensionService.AddButtonToolExtension(_ 
     WorkItem, _ 
     commandKey, _ 
     New ButtonToolAppearance(elementDescription), _ 
     menuGroupKey, _ 
     WorkItem.Commands(commandName)) 
End Sub 

但我們引發事件從一種形式,一個控制器來處理邏輯:

sample_View.vb:

<EventBroker.EventPublication(Constants.Events.CreateNewNavTab, PublicationScope.Global)> _ 
    Public Event CreateNewNavTab As EventHandler 

    ' Node in Navigation Tree is double clicked 
    Private Sub NavTree_DoubleClick(sender As System.Object, e As System.EventArgs) Handles NavTree.DoubleClick 
... 
     RaiseEvent CreateNewNavTab(Me, Nothing) 

    End Sub 

sample_controller。 vb:

' A new tab is created from the Nav Tree. 
<EventSubscription(Constants.Events.CreateNewNavTab, ThreadOption.UserInterface)> _ 
Public Sub CreateNewNavTab(ByVal pNavView As Object, ByVal e As EventArgs) 

... 

End Sub 

希望這有助於!

相關問題