Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVMCross and Prism combination

I've been looking into adopting MvvmCross in developing our next generation of software, mainly with the aim of developing tablet UIs for it. I understand that MvvmCross does not currently support WPF but I can see ourselves developing that and contributing it back.

However, I've also noticed that MvvmCross seems to be very light weight in that there is little support for composite UI as described in the Prism guide. Unfortunately, we do need to allow for more complex composited UI scenarios.

Given what is stated in https://stackoverflow.com/questions/10224376/mvvmcross-experiences-hindsight-limitations about forking or rolling your own with MvvmCross as a reference, and given that we do need more complex UI scenarios than those that MvvmCross provides, what would the best course of action be, fork and reimplement the parts of prism we need, try to get MvvmCross to work together with Prism as is, or develop our own from the inspiration of MvvmCross and MonoCross?

like image 625
Arthur van Leeuwen Avatar asked Dec 13 '12 15:12

Arthur van Leeuwen


1 Answers

Update: See Second answer below...


I might need to write a longer answer to this tomorrow...

As an initial answer:

  • someone has already done a port of MvvmCross to Silverlight and the developers have suggested this might become available to the wider community
  • the PCL version of MvvmCross should be quite straight-forward to port to WPF - although possibly not if older .Net Runtime versions are required
  • as the chief dev of MvvmCross to date, I'm personally interested in supporting WPF - especially right now for my project http://github.com/slodge/BallControl which needs a desktop to run in (Windows Store is crippled - pah!)
  • composite UIs are supported in MvvmCross - e.g. tabs, pivots, panoramas, splits, modal children, etc - but there's not much work been done yet on a full composite UI like often seen in Prism.
  • I have seen people combine MvvmCross with other IoC frameworks, but (no work that I know of) has been done to date on combining MvvmCross with MEF (which is often used with Prism?)

If I were tackling this problem area, then I'd come at this:

  1. Make sure we try to get a working app out first and foremost - the app matters more than the framework.
  2. For framework, I'd try porting the basic IoC setup across first and some simple navigation
  3. For the custom navigation (for displaying UIs in regions) I'd look at the role of the Presenter in MvvmCross - this is what I use in Tab examples, in iPad split view examples, etc to provide complex UI features.
  4. If this custom navigation isn't enough I'd look at how it might be changed/replaced/extended - my guess is that the genuine requirements for WPF/Prism will actually be quite similar to the genuine requirements for bigger iPad, Surface and Nexus tablet apps.
  5. I'd try to keep everything modular and optional so that small phone apps don't have to pull in big navigation processes that bigger apps might need. The downside of this might be lots of projects and DLLs!
  6. I'd also be open to this splitting into separate project(s) - much of the modern software world is ruled by small targetted apps rather than bigger, sprawling frameworks.
  7. Because I'm part time on Mvx, and this is your full time job, I'd definitely recommend you don't let Mvx hold you back!

My initial reaction is 'yes, I'd be really interested in working on this' - the downside (as above) is that I'm only spare time on mvx....


Here's the second answer...

  • I took the WinRT version of MvvmCross as a base (but also used elements of Console, WP7, Touch and Droid too)
  • I produced a simple WPF version of MvvmCross - https://github.com/slodge/MvvmCross/tree/vnext/Cirrious/Cirrious.MvvmCross.Wpf
  • The main feature of this version is that it doesn't contain much in the way of navigation
    • e.g. don't try calling Back!
    • e.g. the main presenter is left abstract for the application UI to implement - see https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross.Wpf/Views/MvxWpfViewPresenter.cs


  • I then took the TwitterSearch demo app - https://github.com/slodge/MvvmCross/tree/vnext/Sample%20-%20TwitterSearch/TwitterSearch.UI.Wpf
    • created some simple views (using cut and paste of Xaml from WP7 version)
    • created a simple Region based presenter - see how RegionAttribute is used in https://github.com/slodge/MvvmCross/blob/vnext/Sample%20-%20TwitterSearch/TwitterSearch.UI.Wpf/MultiRegionPresenter.cs and in https://github.com/slodge/MvvmCross/blob/vnext/Sample%20-%20TwitterSearch/TwitterSearch.UI.Wpf/MainWindow.xaml.cs
    • that was kind of it... give or take a couple of hours of debugging

There's a video of this in action - with some explanation at: http://youtu.be/pYkLxqpu_5E


This is obviously only a first step in Wpf support, but I suspect it is already going to satisfy quite a few use cases... Please feel free to fork the source tree and to extend or replace this first attempt. Also, if it doesn't work for you, then feel free to abandon it and try something else instead.

I will try to work on this more - but can't really prioritise it above paid work... but I am open to being paid to work on mvvmcross too :)

like image 73
Stuart Avatar answered Nov 10 '22 15:11

Stuart