prism vs mvvm light for UWP application

11,111

Solution 1

TL;DR: Compile the latest Prism code in anticipation of the new NuGet packages.

First of all a small intro on Prism to get everybody on the same foot. Prism is a MVVM guidance/framework created by Microsoft Patterns & Practices. They released up to version 5 for WPF/Silverlight. Next to that they also released Prism for Windows Runtime for Windows 8 and later updated to Win8.1/WP8.1 RT. These are 2 different codebases with the second one being more lightweight in the aspect of regions etc, but giving very useful support for application lifecycle management. It's a common misconception to think they're the same.

In March, ownership of Prism was transferred to the community as an open source project and is available on GitHub. They decided to move forward, merge the common code in a PCL core assemby and add support for Xamarin Forms.

As of today there is no RTM release of Prism 6 for UWP yet. The codebase is pretty close to be released with only a few minor issues open, but nothing major preventing most users to use the bits already. At this point of time I would tell you to clone the GitHub repository, compile the assemblies and start porting your app. There are a few breaking changes (mainly namespaces), but you should be up and running in no time. Once the RTM packages are available, drop the hard references and use NuGet.

I have already ported one of our smaller apps and I'm planning to port one of the larger LOB ones (over 60 screens) this weekend.


To come back to the discussion which MVVM framework to use. If you have an app of just a few pages, don't bother using a framework and keep your MVVM simple. If you're going for complex LOB apps, these frameworks have their advantages (and of course disadvantages). There are plenty of choices (MVVM Light, Prism, Caliburn Micro, ...) and all of them are good.

The fact that your colleagues choose for Prism might have a reason like Depechie mentioned. In first place I'm thinking about application lifecycle management where Prism has far superior support for.

With a correct use of base classes you should be able to refactor away most of the dependencies from every single ViewModel in case you want to switch to another framework after all.

The major differences (on top of my head) between Prism for Windows Runtime and MVVM Light that you will have to tackle when switching are VisualStateAwarePages, ViewModelLocator (auto vs property for each view), BindableBase for INotifyPropertyChanged and everything about application lifecycle management. Both frameworks are good, but I wouldn't recommend switching a full blown LOB application between them as it's just too much work (introducing possible bugs).

Solution 2

Windows 10 UWP apps are far less suitable to any of the frameworks you mention. Their rich navigational capabilities and adaptive layouts means that it's hard to see how Prism would work well for you. As regards to MVVMLight, it offers very little above you rolling your own viewmodels, and by avoiding it you can dodge the possibility of a nasty lock-in that will bite you later (which it often does)

Share:
11,111
Aakansha
Author by

Aakansha

Updated on June 04, 2022

Comments

  • Aakansha
    Aakansha almost 2 years

    We have a working project in Windows 8.1 which is made compatible to Win 10. Now the requirement is to convert this project to UWP. In the earlier project, we have used PRISM as the framework for MVVM. Now the problem is that for UWP application, the new version for Prism is not yet released and we are considering to use MVVMLight.

    I am new to both these frameworks, ie, PRISM and MVVMLight. Now my question is how difficult will it be to move the codebase from PRISM to MVVMLight. If it will be difficult, should be wait for PRISM newer version to be released. And if we should move to MVVMLight, what major changes need to be done.

    According to my observation, the codebase is highly coupled with PRISM where there is extensive use of interfaces like IResourceLoader, ISessionStateService and so on throughout the code. Also, I read that PRISM has a learning curve while MVVMLight does not. So if we do decide to move to MVVMLight, will I have to learn PRISM first to understand the codebase and then learn MVVMLight to port the codebase. If we decide to wait for newer version of PRISM to be released which is sometime this week, will there be major code changes?

    How is Unit Testing supported with respect to both framework.

    Since, there is not much time allotted for this task, which will be most efficient way to go ahead with?

  • Aakansha
    Aakansha over 8 years
    Thanks Bart. I have one QQ, Is Prism 6.0 is just migration of code with new namespace and support of base libraries of UWP ?. Does it also supports all the controls of UWP like adaptive triggers, relative panels etc with new prism 6.0?
  • Bart
    Bart over 8 years
    Controls (e.g. Relative panels) and adaptive triggers is purely UI matter. That is something you normally don't deal with in your MVVM framework unless you want data to go back to your model via binding / command / behavior.