Version

ToolWindowLoaded Event

Occurs when a PaneToolWindow is created and about to be shown for the first time.
Syntax
'Declaration
 
Public Event ToolWindowLoaded As EventHandler(Of PaneToolWindowEventArgs)
public event EventHandler<PaneToolWindowEventArgs> ToolWindowLoaded
Event Data

The event handler receives an argument of type PaneToolWindowEventArgs containing data related to this event. The following PaneToolWindowEventArgs properties provide information specific to this event.

PropertyDescription
Handled (Inherited from System.Windows.RoutedEventArgs)Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
OriginalSource (Inherited from System.Windows.RoutedEventArgs)Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
RoutedEvent (Inherited from System.Windows.RoutedEventArgs)Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source (Inherited from System.Windows.RoutedEventArgs)Gets or sets a reference to the object that raised the event.
Window Returns the Infragistics.Windows.DockManager.PaneToolWindow associated with the event.
Remarks

This event is fired when a new PaneToolWindow is created and is about to be displayed. This event will not be raised if the window is hidden and then reshown.

Example
This sample demonstrates handling the ToolWindowLoaded and Unloaded events to add handlers to the ToolWindow created for floating panes within the XamDockManager.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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
using Infragistics.Windows.DockManager;
using Infragistics.Windows.DockManager.Events;

private void InitializeDmWithLoadEvents(XamDockManager dockManager)
{
	// 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<PaneOptionsMenuOpeningEventArgs>(this.XamDockManager_OptionsMenuOpening));

	dockManager.ToolWindowLoaded += new EventHandler<PaneToolWindowEventArgs>(this.XamDockManager_ToolWindowLoaded);
	dockManager.ToolWindowUnloaded += new EventHandler<PaneToolWindowEventArgs>(this.XamDockManager_ToolWindowUnloaded);
}

private void XamDockManager_ToolWindowLoaded(object sender, PaneToolWindowEventArgs e)
{
	// 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<PaneOptionsMenuOpeningEventArgs>(this.XamDockManager_OptionsMenuOpening));
}

private void XamDockManager_ToolWindowUnloaded(object sender, PaneToolWindowEventArgs e)
{
	// unhook the event we hooked in the Loaded event
	e.Window.RemoveHandler(ContentPane.OptionsMenuOpeningEvent,
		new EventHandler<PaneOptionsMenuOpeningEventArgs>(this.XamDockManager_OptionsMenuOpening));
}

private void XamDockManager_OptionsMenuOpening(object sender, PaneOptionsMenuOpeningEventArgs e)
{
	// 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.
	MenuItem mi = 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);
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also