我在我的应用中使用Composite Application Block。有两个概念,EventHandlers和CommandHandler看起来与我非常相似......两者都允许你在另一个UI的一个部分调用功能。他们之间有什么区别?
答案 0 :(得分: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
希望这有帮助!