What's New in Prism 4.0
Prism 4.0 includes guidance in several new areas, resulting in new code in the Prism Library, new and updated QuickStarts, a new reference implementation, and updated documentation. Parts of the Prism Library changed between Prism 2.0 and Prism 4.0 to support the new guidance, fix existing issues, and respond to community requests.
New Guidance
Prism 4.0 contains several areas of new guidance as follows:
- The Model-View-View Model (MVVM) approach to building Windows Presentation Foundation (WPF) and Microsoft Silverlight applications is explained in depth in Chapter 5, "Implementing the MVVM Pattern", and in Chapter 6, "Advanced MVVM Scenarios."
- Both region-based and state-based approaches for integrating navigation into an application are explained in Chapter 7, "Composing the User Interface."
- The option to use the Managed Extensibility Framework (MEF) instead of Unity as a dependency injection container is explored in Chapter 3, "Managing Dependencies Between Components."
- Prism extensibility points are discussed in Appendix E, "Extending Prism."
- The signed Prism Library for Windows Phone 7 includes a subset of the Prism and Prism.Interaction library targeted to Windows Phone 7. This includes the Prism event aggregator, commands, view model, and interaction request. For information about using the Prism Phone Library, see the Windows Phone 7 Developer Guide community site at http://wp7guide.codeplex.com/.
Updated Guidance
The Prism documentation has been reorganized so that you can find scenario-based topics easily. The key scenarios that Prism addresses are organized by chapter. Each chapter also includes key decisions that you should think about. The documentation for the reference implementations, Hands-on Labs, and QuickStarts have been moved into appendixes.
Changes in the Prism Library
Prism Library 4.0 includes many changes related to new functionality, code organization, and APIs.
Code Organization
The following organizational changes were made to the library:
- The Composite Application Library was renamed to the Prism Library.
- The Composite and Composite.Presentation portions of the namespaces were removed and the Composite and Composite.Presentation assemblies collapsed into a single assembly named Microsoft.Practices.Prism.
- The Microsoft.Practices.Prism libraries for Silverlight and WPF now register the Microsoft.Practices.Prism.Regions, Microsoft.Practices.Prism.Commands, and Microsoft.Practices.Prism.ViewModel namespaces with the http://www.codeplex.com/prism xmlns definition.
- Several reusable user interface (UI)–based behaviors were extracted into the Prism.Interactivity assembly, including the interaction request behavior.
- You can now use MEF as the dependency injection container. This functionality required two new projects in the Prism Library solutions: Prism.MefExtensions.Desktop and Prism.MefExtensions.Silverlight. These projects create a new assembly, Microsoft.Practices.Prism.MefExtensions.dll, in the respective Desktop and Silverlight folders. Also included in the solutions are new unit test projects for the new functionality.
API Changes
The Prism Library API changed in several key areas. The bootstrapper was heavily modified and reusable code was added to support the new areas of guidance provided in Prism.
Bootstrapper API Changes
The addition of MEF support resulted in several changes to the Prism Library's bootstrapper. These changes include the following:
- A new Bootstrapper base class was added to the Microsoft.Practices.Prism namespace in the Prism.Desktop and Prism.Silverlight projects.
- The UnityBootstrapper class (in the Microsoft.Practices.Prism.UnityExtensions.Desktop and Microsoft.Practices.Prism.UnityExtensions.Silverlight namespaces) extends the new Bootstrapper base class.
- A new MefBootstrapper class (in the Microsoft.Practices.Prism.MefExtensions.Desktop and Microsoft.Practices.Prism.MefExtensions.Silverlight namespaces) extends the new Bootstrapper base class.
- To facilitate the addition of the Bootstrapper base class, names of the following properties and methods were changed for consistency:
- The LoggerFacade property was renamed to Logger.
- The Logger property is set in the Run method of the different bootstrappers, using the result of the CreateLogger method rather than the get property on the Logger.
- The GetModuleCatalog method in the Bootstrapper is now called CreateModuleCatalog.
- Several new methods were added to better separate concepts:
- The virtual ConfigureModuleCatalog was added to allow modifying the catalog after creation as part of the bootstrapping process.
- The virtual ConfigureServiceLocator method was added to allow overriding the configuration of the ServiceLocator.
- ModuleManager now includes the ModuleDownloadProgressChanged and LoadModuleCompleted events to monitor module download progress and to determine when a module has completed loading.
For more information about the bootstrapper classes, see Chapter 2, "Initializing Prism Applications." For a full API description of the bootstrapper, see UnityBootstrapper and MEFBootstrapper in the Prism 4 API Reference help file.
Additions to the Prism Library Core API
The following namespaces were added to the Prism Library to support the new areas of guidance added in Prism 4.0:
Microsoft.Practices.Prism.ViewModel was added to help you develop MVVM-based applications.
Microsoft.Practices.Prism.Regions includes several new classes to assist you in integrating navigation into a Prism region-based application.
Prism introduces a new RegionMemberLifetimeBehavior that removes views from a region when they become deactivated. Either the view or its view model can opt in to this by using the RegionMemberLifetimeAttribute or the IRegionMemberLifetime interface. For more information, see the RegionMemberLifetimeBehavior in the Prism 4 API Reference help file.
Example Code Changes
Prism 4.0 contains over a dozen separate code samples that demonstrate portions of the provided guidance. Several samples from Prism 2.0 were removed or replaced, and new samples added.
The following samples were added for Prism 4.0:
- Basic MVVM QuickStart. This QuickStart shows a very simple MVVM application and covers the core concepts. For more information, see Basic MVVM QuickStart.
- MVVM QuickStart. This QuickStart expands upon the Basic MVVM QuickStart and demonstrates additional scenarios that are more complex. For more information, see MVVM QuickStart.
- MVVM Reference Implementation. This reference implementation shows many scenarios in a real-world inspired application. The MVVM scenarios shown are more complex and full-featured than in the related QuickStarts. For more information, see MVVM Reference Implementation.
- View-Switching Navigation QuickStart. This QuickStart demonstrates how to use the Prism region navigation API. For more information, see View-Switching Navigation QuickStart.
- State-Based Navigation QuickStart. This QuickStart shows an approach that uses the Silverlight Visual State Manager to define the views (states) and the allowed transitions. For more information, see State-Based Navigation QuickStart.
- UI Composition QuickStart. This QuickStart replaced the View Injection QuickStart and the View Discovery QuickStart from Prism 2.0. In Prism 4, both concepts are shown in one example application. For more information, see UI Composition QuickStart.
- Modularity QuickStarts. There are four separate QuickStarts that show the same application implemented for both WPF and Silverlight, using both Unity and MEF. These four QuickStarts replace the following QuickStarts from Prism 2.0 (Configuration Modularity QuickStart, Defining Modules in Code QuickStart, Directory Lookup Modularity QuickStart, and Remote Module Loading QuickStart). For more information, see Modularity QuickStarts for WPF and Modularity QuickStarts for Silverlight.
The Stock Trader Reference Implementation was updated to use the MVVM and navigation concepts, and it was converted from using Unity to using MEF as the dependency injection container.
The following samples were removed from Prism because they were replaced by the UI Composition QuickStart, Modularity QuickStarts for WPF, and the Modularity QuickStarts for Silverlight:
- View Injection QuickStart
- View Discovery QuickStart
- Configuration Modularity QuickStart
- Defining Modules in Code QuickStart
- Directory Lookup Modularity QuickStart
- Remote Module Loading QuickStart
Miscellaneous Changes
Several other changes occurred in Prism 4.0, including:
- The Prism License changed to the Microsoft patterns & practices license. Please see http://compositewpf.codeplex.com/license for details. The license is also included in the EULA.txt file in the root Prism folder.
- Strong-named and authenticode signed Prism binaries are now included in Prism 4.0 and are located in the bin folders. All projects that use the Prism binaries now look for them in {prism}\Bin\{platform}
- You can use the UpdatePrismBinaries.bat batch file to rebuild the Prism binaries. The batch file is located in the folder in which you extracted Prism.
Note:This will replace the files in the {prism}\Bin\ folders. - You can use the RegisterPrismBinaries.bat batch file to register the Prism binaries with Visual Studio. The batch file is located in the folder in which you extracted Prism.
- The Moq binaries are now included with Prism in the following location:
- Moq binaries for WPF are in the {prism}\Lib\Desktop\Moq folder.
- Moq binaries for Silverlight are in the {prism}\Lib\Silverlight\Moq folder.
More Information
For more information about how to upgrade a solution from version 2.x to version 4.0 of the Prism Library, see Upgrading from Prism 2.x.
For more information about Moq, see http://code.google.com/p/moq/.
Last built: August 28, 2012

