What is Prism for WPF? - wpf

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.

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.

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.

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.

Related

WPF Desktop application and design patterns

I have to develop a desktop application and the back end will be SQL Express.
I am new to wpf.
Any design patterns i can use? any sample application for wpf with db?
Please help me.
Prism 4 is by Microsoft Patterns and Practices team and it advocates MVVM, Dependency Injection, and modular application development. The book (which I bought and read) is now free online. The book covers several design practices and should be a fairly good start to everything you would need to know to write maintainable, testable, flexible applications in WPF. Prism is also a framework which aids in modular app development and MVVM. It is also fairly popular.
Prism 4.1
^ Seriously, read this book. It takes 2 days max.
As per my suggestion MVVM pattern would be nice if you use in your application. Because it has many ways to reuse your code.
You can find tutorial on the same at below links:
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
http://www.codeproject.com/Articles/126249/MVVM-Pattern-in-WPF-A-Simple-Tutorial-for-Absolute
http://wpftutorial.net/MVVM.html
Let me know if you need more help.
You can use MVVM design pattern, It will help you to Reuse of code, Flexibility and Customization, Separation of the UI design and development , Testing ...
Refer these article to understand the MVVM pattern and also for sample WPF application..
http://www.codeproject.com/Articles/278901/MVVM-Pattern-Made-Simple
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
http://msdn.microsoft.com/en-us/library/gg405484%28v=pandp.40%29.aspx

Prism - Bad idea to use it?

I have been migrating from Windows Forms to WPF and am trying to utilize Prism to meet the requirement that the application be plug-in oriented.
My problem is that there is seemingly no support for it. I have also heard that it is extremely leaky in some cases. Being I am developing an enterprise application, this is unacceptable.
If this is the case, and it is a bad idea to start using Prism, is there any alternatives to make a composite application? Solely using MEF is all I can think of.
With Prism you have the option to use Unity and/or MEF as the IoC/DI framework....it's also quite extensible...so you can plugin different IoC containers if you wish.
Some of the problems with leaks can usually come down to not using WPF in a certain way e.g. need to use Weak delegates / Weak event patterns, etc.
You could roll your own plug-in framework using MEF, but you'll probably need to re-invent some of the things Prism already does for you e.g. an EventAggregator, etc.
You could pick an alternative framework, they all have their strengths and weaknesses.
Alternatives to Prism + MEF for modular MVVM apps
There's another Microsoft technology that is geared to supporting plug-ins namely, System.AddIn/Managed Add-in Framework (MAF)....but you have to put in a bit more scaffolding.
http://www.matthidinger.com/archive/2008/10/12/managed-addin-framework-system.addin-with-wpf.aspx
Someone has come up with a framework that uses MEF here:
http://www.codeproject.com/Articles/43625/Building-an-Extensible-Application-with-MEF-WPF-an
If you want to look at an Enterprise size project with their own very plugable/modular architecture then look at SharpDevelop for inspiration.
http://www.icsharpcode.net/OpenSource/SD/
....and it's not beyond the bounds of possibility, if you really want, to combine the best bits from several frameworks.

Prism EventAggregator and MVVM Light Messenger Summary

Can someone please give me good overview of the Prism EventAggregator in comparison to the MVVM Light Messenger service? Specifically;
Are they similiar things, or meant for wholly different purposes?
The pros and cons of both
Where they should and should not be used
Use in modular development, such as when used in conjunction with MEF or Unity
Other information you deem relevant
This is something that I have not seen addressed much, and I find myself still using both in the same project, when my gut feel says I should use one or the other.
EventAggregator and Messenger are similar. They both are used to decouple the communication between different components which are used in a composite application. in most cases they both offer similar features.
Messenger has the option of brodcasting to all the subscribers or to targetted subscribers using a key. I am not sure if such a feature exists in EventAggregator.
In terms of Pros and Cons, MVVMLight is very lightweight. Prism comes with other related dll's. If your don't want to use all the features of Prism you can just make use of EventAggregator.
Althought I haven't used any of these frameworks with MEF or Unity, but since they are lke utilities / helpers / addins or whatever you call they should be able to work.

What MVVM Framework (Silverlight) should I use?

I'm working on Silverlight, of course I use MVVM. I found many problems but I can create work-around solution for them (some of these solution is not elegant at all), now I think it's time to bring some framework to help me.
I need functions that listed below.
Dependency Injection
Navigation
Callback
Messaging
Bind event to Command
Testability
As I know, there are many Framework out there, such as, Jounce, MVVMLight and Prism. I want to know which framework is suitable for my need?
When it comes to dependency injection I'd rather use MEF
which greatly simplifies code. As for the rest of the functions , currently I'm working with MVVMLight and I haven't faced any problem (although I'm not familiar with Jounce and Prism)
I think that you should consider the scale of the application. If it is a relatively small application that is unlikely to grow I would choose MVVMLight.
For a larger LOB application I would consider PRISM or Caliburn. I would also recommend reading blog posts by John Papa and Jeremy MIller on MVVM, Screens and Coordinators. Their ideas and insights helped enormously in a large scale Silverlight project I've built.
In WPF Prism is great, in Silverlight Jounce is the best by far. Its is very well integrated with MEF , very lightweight, elegant and stable. It also provides nice implementation to support complex events workflow scenarios, VisualStateManager in ViewModel (love that one), validation, debugging and unit testing; Used it in some quite complex projects and was happy I chose it.

Compare and contrast Caliburn v. MVVM Light Toolkit (mainly for Silverlight)?

I want to learn more about a MVVM framework but I don't have a lot of time to devote. Does someone have experience with Caliburn (or micro Caliburn) and MVVM Light Toolkit and can give some reasons to start with one framework over the other? This would mainly be for Silverlight development.
Or perhaps is there another framework that might be easier to start with?
thanks
Have a look at this nice article that provides a summary and comparison of various MVVM frameworks - http://www.japf.fr/2009/10/a-quick-tour-of-existing-mvvm-frameworks/. The choice of an MVVM framework depends on the time available and the complexity of your project. If you wish to learn how to use a MVVM framework, it is best to work on a small project first in which you explore one or more frameworkss. MVVMLight and Caliburn are popular frameworks and they are used by both Silverlight and Windows Phone 7 developers. There are numerous sample applications available on the web that illustrate the use of these frameworks.
HTH, indyfromoz

Resources