141

I've come across something called Prism a lot recently. Microsoft, who run the project, describe it as

Guidelines for composite applications in WPF and Silverlight.

Even after reading the more detailed descriptions out there, I have next to no clue what it's actually about, I'm afraid.

I'm hoping here that someone could give me a clear succinct explanation of what Prism actually is and why I should learn it. I have been a WPF developer for a couple of years now, used MVVM my fair share, and have lately encountered people using Prism, but personally feel a bit out of the loop here.

In particular, I'm wondering about the following points:

  • Is Prism literally just (or mainly) a booklet, as given on the MSDN site? Does it include any libraries, if so for what exactly?

  • Is Prism an MVVM framework? Should I be using it as the "official Microsoft MVVM framework" over others out there or my own?

  • Does it provide dependency injection? Does it relate to MEF at all in this way?

  • Anything else I should know about what Prism does, as a WPF/Silverlight developer.

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Noldorin
  • 144,213
  • 56
  • 264
  • 302
  • 5
    It's actually a fairly complex thing, too - Prism tries to fill a lot of needs, so it's tough to get a single "right" answer if you're trying to figure out its purpose. It really does multiple things. – Reed Copsey Jun 08 '11 at 01:48
  • 1
    This similar question asked by me is also having some good answers to this question - http://stackoverflow.com/questions/6251821/custom-mvvm-implementation-vs-prism – akjoshi Jun 08 '11 at 07:08
  • 9
    yet another murky quagmire from P&P. every time they release something like this I find myself having to go to SO or wikipedia to find out what the thing actually is. why does it always have to be so cryptic? – Adam Ralph May 14 '13 at 07:42
  • 1
    if you like, it is a kind of documentation that guide you to how implement MVVM pattern in your WPF/Silverlight applications. there is also a library from codePlex which i am not sure what is it exactly for. a good documentation about PRISM lives in below link, it worth if have a look at it: [Prism 4.1 - Developer's Guide to Microsoft Prism - MSDN](http://msdn.microsoft.com/en-us/library/gg406140.aspx) – user3353518 Feb 25 '14 at 22:51

3 Answers3

94

Prism is the Microsoft Patterns and Practices Team official guidance for building "composite applications" in WPF and Silverlight.

It's intended to provide guidance on the best practices for building large scale applications which are flexible in terms of development and maintainability.

This includes guidance on dependency injection (via Unity or MEF), layout (including using MVVM), composite event handling, etc.


Is Prism literally just (or mainly) a booklet, as given on the MSDN site? Does it include any libraries, if so for what exactly?

It is a book, but also includes the libraries for support (on the GitHub site).

Is Prism an MVVM framework? Should I be using it as the "official Microsoft MVVM framework" over others out there or my own?

Yes and no. It includes guidance for using MVVM, but is far more than an MVVM framework. It's really not, in and of itself, an "MVVM framework" - though it does include MVVM guidance.

Does it provide dependency injection? Does it relate to MEF at all in this way?

Yes. It originally included Unity, but the latest release includes using MEF for DI.

Anything else I should know about what Prism does, as a WPF/Silverlight developer.

It's worth taking a look at how they do things. They have a very elaborate "region" concept, as well as good event aggregation support. It also includes good practices for developing against WPF, Silverlight, and Windows Phone simulataneously.

Sabuncu
  • 5,095
  • 5
  • 55
  • 89
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 1
    Thanks for the reply. This gives me a good overview I think. Just to be clear: is there actually any MVVM-related code or a library DLL even? – Noldorin Jun 09 '11 at 16:49
  • 4
    @Noldorin: I'm assuming your asking about inside of Prism... There is some support for MVVM, but frankly, MVVM, as a pattern, requires almost no library support. Prism does have good notification object and commanding support, which is really the only things missing in the BCL you really need for MVVM. It also has the service locator support, which helps if you want to use DI/shared services for VM<->VM communication. It doesn't have some of the "extra" stuff provided by some MVVM "frameworks", such as a messaging framework, etc. – Reed Copsey Jun 09 '11 at 17:27
  • 1
    In order to follow Prism guidance it is mandatory the libraries have been installed? – dios231 Jul 19 '16 at 11:52
19

It's a framework for building WPF and Silverlight apps.

http://compositewpf.codeplex.com/

It used to be called "Prism" before Microsoft renamed it to "CompositeWPF."

Answers:

1) Prism is an MVVM framework to use as a foundation for your applications

2) I suggest so depending on your specific requirements. You should post another question with specific details so you can get some specific answers.

3) Prism uses dependency injection (Unity) but does not "provide" it

4) Imo, Prism provides a lot of functionality but is heavy on the learning curve. For small projects with you as the sole developer, you may not need the abstraction and tools that it provides.

rboarman
  • 8,248
  • 8
  • 57
  • 87
  • 3
    I somewhat disagree with your statement #1 - Prism includes MVVM guidance, but a LOT of the guidance (most samples) are not MVVM at all. It's more presented as one option that can be used when building composite applications. – Reed Copsey Jun 08 '11 at 01:47
  • 1
    I guess I have always used with the MVVM pattern – rboarman Jun 08 '11 at 01:51
1

A more contemporary answer of what Prism is, is answered on the Github home page.

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, Uno Platform and WinUI.

To elaborate, Prism is a collection of libraries to aid in implementing enterprise applications following Microsoft recommended best practice design and architectural patterns.

Prism consists of the following Nuget packages:

  • Prism.Core
  • Prism.Wpf
  • Prism.Forms
  • Prism.Uno

Prism supports different DI (Dependency Inversion) / IoC (Inversion of Control) techniques and libraries. It ships with the Unity library for dependency injection, with additional IoC helper functions and classes.

Some of the areas the libraries address:

  • Decoupled Event messaging and handling
  • Command
  • View Model Navigation
  • INotifyPropertyChanged implementation
  • Dependency Injection

Prism is part of the .NET Foundation.

You may be interested in looking at the Windows Community Toolkit, which follows many of the same principles and patterns adopted by Prism.

cdiggins
  • 17,602
  • 7
  • 105
  • 102