This project has moved. For the latest updates, please go here.


Simplifies the creation of workspaces with and without WPF support.

1. Why should someone need a workspace without WPF support?

Because the support for Windows Presentation Foundation (WPF) requires the .NET Framework 3.0. Without the WPF support the workspace works already with the .NET Framework 2.0. Thus it is common to create two workspaces: one with and one without WPF support.

2. How does the ComposerAdapter work?

The WPF workspace has to use a new composer known as ElementHostWorkspaceComposer. The IWorkspaceComposer interface is responsible to unite the old and new WorkspaceComposer of CAB. To accomplish this the Adapter design pattern is used. Thus a workspace can work with the IWorkspaceComposer interface without knowing which concrete composer implementation it uses. The composer creation can be influenced by a subclass of the workspace. This is done by using the Factory Method design pattern.


  • IWorkspaceComposer: Represents an workspace composer which is independent of the UI technology. (CABExtension)
  • WorkspaceComposer: Provides the composer functionality for Windows Forms controls. (CAB.WinForms)
  • WorkspaceComposerAdapter: Converts the interface of the WorkspaceComposer to the IWorkspaceComposer interface. (CABExtension)
  • ElementHostWorkspaceComposer: Provides the composer functionality for WPF controls. (CAB.WPF)
  • ElementHostWorkspaceComposerAdapter: Converts the interface of the ElementHostWorkspaceComposer to the IWorkspaceComposer interface. (CABExtension.WPF)
  • CustomWorkspace: A new Workspace without WPF support. It creates the required composer via a factory method.
  • CustomWPFWorkspace: Extends the CustomWorkspace and adds the WPF support. It overwrites the factory method to create the ElementHostWorkspaceComposer for the workspace.

3. What is the advantage by using the ComposerAdapter?

It allows to reuse the complete workspace code. The WPF workspace does only need to extend the Windows Forms workspace and add the WPF support as it can be seen in Listing 1:

public class DockPanelWorkspace : Jbe.CABExtension.WinForms.Workspaces.DockPanelWorkspace
    private ElementHostWorkspaceComposerAdapter<Control, DockPanelSmartPartInfo> composer;

    public IWPFUIElementAdapter WPFUIElementAdapter
        set { composer.WPFUIElementAdapter = value; }

    protected override IWorkspaceComposer<Control> CreateWorkspaceComposer()
        composer = new ElementHostWorkspaceComposerAdapter<Control, DockPanelSmartPartInfo>(this);
        return composer;

Listing 1

Last edited Oct 8, 2007 at 1:09 PM by jbe2277, version 8


No comments yet.