Prism version 5.0 for WPF is now available. This version of Prism includes updates to existing and several new NuGet packages:
- Prism.Composition (New)
- Prism.Interactivity (New)
- Prism.Mvvm (New)
We’ve updated Prism 4.1 with bug fixes and a few new features. ...
Prism provides guidance in the form of samples and documentation that help you easily design and build rich, flexible, and easily maintained Windows Presentation Foundation (WPF) desktop applications. Using design patterns that embody important architectural design principles, such as separation of concerns and loose coupling, Prism helps you to design and build applications using loosely coupled components that can evolve independently but which can be easily and seamlessly integrated into the overall application. In short, these applications are "built to last" and "built for change." These types of applications are known as composite applications.
This topic provides a brief overview of the Prism concepts with links to associated source code and documentation.If you are considering upgrading from Prism 4.1 to Prism 5.0 we include a "What’s New" and "Upgrading from Prism 4.1" topic that you should read.
Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF, new and updated QuickStarts, and updated documentation. Parts of the Prism Library changed between Prism 4.1 and Prism 5.0 to support the new guidance, fix existing issues, and respond to community requests.
Prism 5.0 contains several areas of new guidance as follows:
- Prism.Mvvm is a portable class library that encapsulates Prism’s MVVM support. This library includes ViewModelLocationProvider. Views and view models can be wired up together using the new ViewModelLocationProvider’s convention-based approach as explained in Implementing the MVVM Pattern. View model construction can be accomplished using a dependency injection container. The ViewModel Locator’s extensibility points are discussed in Extending the Prism Library.DelegateCommands are now extendable and provide Async support. A new implementation of the INotifyPropertyChanged interface, the BindabaleBase class, was added.
- The PopupWindowAction class was added to the Prism.Interactivity assembly to open a custom window in response to an interaction request being raised.
The InvokeCommandAction action provided by Prism now passes trigger parameters to the associated command.
For more information see Advanced MVVM Scenarios.
- The EventAggregator classes have been moved to the Prism.PubSubEventsportable class library.
- The NavigationParameters class can now be used to pass object parameters during navigation, using the overloads of the RequestNavigate method of a Region orRegionManager instance.
Prism Library 5.0 includes changes related to new functionality, code organization, and APIs.
The following namespaces were added to the Prism Library to support the new areas of guidance added in Prism 5.0:
- Microsoft.Practices.Prism.PubSubEvents was added to help you send loosely coupled message using a portable class library.
- Microsoft.Practices.Prism.Mvvm was added to assist you in implementing MVVM using a portable class library and several platform specific libraries.
- Microsoft.Practices.Prism.SharedInterfaces has been added to share theIActiveAware interface between Prism and Prism.Mvvm assemblies, therefore theIActiveAware interface has been moved to this assembly. It is also intended for future use.
Prism 5.0 contains eleven separate code samples that demonstrate portions of the provided guidance. Several samples from Prism 4.1 were removed or replaced, and new samples added.
The following samples were added for Prism 5.0:
- Basic MVVM QuickStart. This QuickStart shows a very simple MVVM application that uses the ViewModel Locator and show a parent and child ViewModels. For more information, see the MVVM QuickStart.
- MVVM QuickStart. This QuickStart was removed for this version.
- MVVM Reference Implementation. This reference implementation was removed for this version.
- View-Switching Navigation QuickStart. This QuickStart now supports WPF. It demonstrates how to use the Prism region navigation API. For more information, seeView-Switching Navigation QuickStart.
- State-Based Navigation QuickStart. This QuickStart now supports WPF. It shows an approach that uses the 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 now supports WPF. It replaced the View Injection QuickStart and the View Discovery QuickStart from Prism 2.0. In the current versions, both concepts are shown in one example application. For more information, see UI Composition QuickStart.
- Interactivity QuickStart. This new QuickStart demonstrates how to exposes an interaction request to the view through the view model. The interactions can be a popup, confirmation, custom popup, and a more complex case where the popup needs a custom view model. It also shows Prism’s InvokeCommandAction action that passes theEventArgs from the trigger, as a command parameter. For more infromation, seeInteractivity QuickStart.
In your application, you can now use NuGet to add references to the Prism assemblies. These packages include:
Prism provides guidance designed to help you more easily design and build rich, flexible, and easy to maintain Windows Presentation Foundation (WPF) desktop applications.
In this lab and associated sample, you will learn the basic concepts of modular application development using the Prism Library, and apply them to create a solution that you can use as the starting point for building a composite Windows Presentation Foundation (WPF) application. After completing this lab, you will be able to do the following:
- You will create a new solution based on the Prism Library.
- You will create and load a module.
- You will create a view and show it in the shell window.
This lab includes the following tasks:
The Model-View-ViewModel (MVVM) QuickStart provides sample code that demonstrates how to separate the state and logic that support a view into a separate class named ViewModelusing the Prism Library. The view model sits on top of the application data model to provide the state or data needed to support the view, insulating the view from needing to know about the full complexity of the application. The view model also encapsulates the interaction logic for the view that does not directly depend on the view elements themselves. This QuickStart provides a tutorial on implementing the MVVM pattern.
A common approach to designing the views and view models in an MVVM application is the first sketch out or storyboard for what a view looks like on the screen. Then you analyze that screen to identify what properties the view model needs to expose to support the view, without worrying about how that data will get into the view model. After you define what the view model needs to expose to the view and implement that, you can then dive into how to get the data into the view model. Often, this involves the view model calling to a service to retrieve the data, and sometimes data can be pushed into a view model from some other code such as an application controller.
This QuickStart leads you through the following steps:
- Analyzing the view to decide what state is needed from a view model to support it
- Defining the view model class with the minimum implementation to support the view
- Defining the bindings in the view that point to view model properties
- Attaching the view to the view model
- Modularity for Unity Code Sample using the Prism Library 5.0 for WPF
- Modularity for MEF Code Sample using the Prism Library 5.0 for WPF
That should be enough Prism for WPF to get you started at least...