Click to Rate and Give Feedback
MSDN
MSDN Library
Client Development
Application Blocks
 Composite UI Application Block Exte...
Smart Client Software Factory - April 2008
Composite UI Application Block Extensions for WPF

The Smart Client Software Factory includes a new Windows Presentation Foundation (WPF) integration layer that extends the Composite UI Application Block. With this layer, developers can use WPF user controls in the same way as Composite UI Application Block SmartParts and work with them as they do Windows Forms SmartParts. Figure 1 illustrates the Windows Presentation Foundation Integration QuickStart.

Cc540739.note(en-us,MSDN.10).gifNote:
The Windows Presentation Foundation integration layer for the Composite UI Application Block does not replace the Composite UI Application Block Windows Forms layer. Smart client applications developed with the software factory still use Windows Forms for UI infrastructure elements; therefore, the Windows Forms layer is required.

Cc540739.scsf-WPFExtensions-01(en-us,MSDN.10).png

Figure 1
Windows Presentation Foundation Integration QuickStart

Design Goals

The design goals for adding the WPF integration layer to the Smart Client Software Factory are the following:

Allow users to use both Windows Presentation Foundation and Windows Forms controls as Composite UI Application Block SmartParts.

Provide a seamless migration path for existing Windows Forms solutions.

The Windows Presentation Foundation integration layer for the Composite UI Application Block includes a set of workspaces and associated components that allow smart client developers to use WPF controls as SmartParts.

Workspaces

The WPF integration layer includes new implementations of the Windows Forms Composite UI Application Block workspaces. The following workspaces are part of the Microsoft.Practices.CompositeUI.WPF namespace, and add support for WPF controls:

  • WindowWorkspace
  • MdiWorkspace
  • TabWorkspace
  • DeckWorkspace
  • ZoneWorkspace

To support WPF controls, the workspaces use the WPFUIElementAdapter service to wrap the controls in ElementHost elements. ElementHost elements are Windows Forms controls that can host a Windows Presentation Foundation (WPF) element in Windows Forms controls or forms.

WPF Application Startup Class

The Windows Presentation Foundation integration layer for the Composite UI Application Block includes a new class named WPFFormShellApplication that extends Microsoft.Practices.CompositeUI.WinForms.FormShellApplication. This class performs the following initialization tasks to add support for WPF SmartParts:

  • It adds a new builder strategy, WPFControlSmartPartStrategy,to the root ObjectBuilder object. This strategy walks WPF controls containment chain and looks for child controls that are smart parts, placeholders, or workspaces, and adds them to the WorkItem that will contain the WPF control.
  • It registers the WPFUIElementAdapter service with the root WorkItem. This service wraps WPF controls in ElementHost elements so they can be hosted in Windows Forms applications.

To enable your solution to support WPF controls as SmartParts, your application startup class must inherit from WPFFormShellApplicationclass.

Creating WPF SmartParts

To create a SmartPart, you can use the Add WPF-View (with presenter) recipe included in the Smart Client Development guidance package. For more information, see How to: Add a WPF-View with a Presenter.

Using WPF SmartParts

To use WPF controls as SmartParts, you can follow the same patterns that you use for Windows Forms controls. See the following procedures in the Creating and Showing SmartParts topic:

  • To display a SmartPart in a SmartPartPlaceholder
  • To display a SmartPart in a Workspace

Related Factory Assets

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker