Imports Infragistics.Windows.DockManager
Imports Infragistics.Windows.DockManager.Events
Private Sub InitializeDmWithLoadEvents(ByVal dockManager As XamDockManager)
' the OptionsMenuOpening event is a bubble event so we'll
' handle it on the dockmanager. however, since panes in
' floating windows are in top level wpf windows, the events
' will not bubble to the dockmanager so we will use the
' ToolWindowLoaded event to hook the event on the toolwindow
' as well.
dockManager.AddHandler(ContentPane.OptionsMenuOpeningEvent, New EventHandler(Of PaneOptionsMenuOpeningEventArgs)(AddressOf Me.XamDockManager_OptionsMenuOpening))
AddHandler dockManager.ToolWindowLoaded, AddressOf Me.XamDockManager_ToolWindowLoaded
AddHandler dockManager.ToolWindowUnloaded, AddressOf Me.XamDockManager_ToolWindowUnloaded
End Sub
Private Sub XamDockManager_ToolWindowLoaded(ByVal sender As Object, ByVal e As PaneToolWindowEventArgs)
' the toolwindows are top level windows (at least when running in a window
' application) so events will not route to the dockmanager. we can use
' this event to hook such events or add elements into the resources chain
'
e.Window.AddHandler(ContentPane.OptionsMenuOpeningEvent, New EventHandler(Of PaneOptionsMenuOpeningEventArgs)(AddressOf Me.XamDockManager_OptionsMenuOpening))
End Sub
Private Sub XamDockManager_ToolWindowUnloaded(ByVal sender As Object, ByVal e As PaneToolWindowEventArgs)
' unhook the event we hooked in the Loaded event
e.Window.RemoveHandler(ContentPane.OptionsMenuOpeningEvent, New EventHandler(Of PaneOptionsMenuOpeningEventArgs)(AddressOf Me.XamDockManager_OptionsMenuOpening))
End Sub
Private Sub XamDockManager_OptionsMenuOpening(ByVal sender As Object, ByVal e As PaneOptionsMenuOpeningEventArgs)
' the OptionsMenuOpening event is raised when you right click on a
' pane's caption or tab item as well as when you click the window
' position menu item in the caption and allows you to add/remove
' items from the menu.
Dim mi As New MenuItem()
mi.Command = ApplicationCommands.Save
' to have the menu items use the same styling as the default
' menu items, we'll associate it with the same style that
' the dockmanager uses for its menu items
mi.SetResourceReference(MenuItem.StyleProperty, XamDockManager.MenuItemStyleKey)
e.Items.Add(mi)
End Sub