Table of Contents
Activating a DockItem

call DockContainer.ActivateItem to activate a dock item:

//Activate "Property View"
DockContainer.ActivateItem("PropertyView");

The above code searches for a DockItem whose ItemId matches "PropertyView" in all loaded DockItem objects. If it can find it, then it calls the DockItem's Activate method to activate the dock item.

If no matching DockItem is found, the DockContainer first raises DockViewNeeded event, then DockItemNeeded event to allow you to create the DockView object for the item, and the DockItem object respectively. You must handle these two events in order to for ActivateItem to be able to dynamically load new items.

The following code demonstrates how to handle DockViewNeeded event:

<eo:DockContainer x:Name="DockContainer1" DockViewNeeded="DockContainer_DockViewNeeded" ...>
....
</eo:DockContainer>

The above code also demonstrated a technique that you can either create a new view, or simply return an existing view based on the item id passed in to ActivateItem method.

Once the DockView is created, DockContainer raises DockItemNeeded event. You must also handle this event to create the new item:

<eo:DockContainer x:Name="DockContainer1" DockItemNeeded="DockContainer_DockItemNeeded" ...>
....
</eo:DockContainer>

Here PropertyWindow is a class that derives from DockItem and contains the corresponding UI elements for editing properties.

You can also load a DockView from an XAML file by calling DockItem.LoadFrom method:

//Load a DockItem from an XAML file
e.Item = DockItem.LoadFrom(new Uri("EO.Wpf.Demo;component/DemoDockItem.xaml", UriKind.Relative));

The ActivateItem method returns the DockItem that has been activated. So you can use the returned value to perform additional initializations if needed:

//Activate "Property View"
PropertyWindow propertyWindow = (PropertyWindow)DockContainer.Activate("PropertyView");

//Perform additional initializations
propertyWindow.Content = ....