why mvvmcross?

batmacibatmaci DEMember ✭✭✭✭✭

I am keep hearing and reading mvvmcross for xamarin. I have experience mvvm with wpf and can i just use it as use it on wpf? What makes mvvmcross easier or is there something which i cant achieve with mvvm that i can only achieve with mvvmcross? can I somebody shed some lights on this?

thanks you very much

Best Answer


  • batmacibatmaci DEMember ✭✭✭✭✭

    I have more exprience with MVVMlight and I also in my xamarin app but I would like to know if there is any benefit to use MVVMCross over MVVMlight. as far as i read about it. it looks promising and challenging.

    I didn't want to weigh down my project with a large MVVM framework.

    do you mean that MVVMCross increases app size or it slows down the project regards to performance?

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @batmaci - I wouldn't say any slow down, as for app size not that much but a little. What that really means is there is a large framework and it can be adding more complexity and features that you would ever use. I tend to only install packages or code that I need when possible (I know the .NET framework is a large exception here).

    Otherwise on larger projects you might end up having developers do the same thing 3 different ways, just because they had the capability to.

  • batmacibatmaci DEMember ✭✭✭✭✭

    @MichaelRidland said:
    @batmaci @AdamP

    I've used MvvmCross alot and it's great for 'Xamarin Traditional' but whenever I use Xamarin.Forms I use FreshMvvm. The reason for this is that MvvmCross (and MvvmLight) have alot of extra code that's not needed in XF eg XF already has a databinding engine, XF gets you 95% of the way to Mvvm without a Framework. The reason for FreshMvvm was to create something like MvvmCross but designed with Xamarin.Forms in mind, the FreshMvvm has built in Mvvm Navigation services for all the XF navigation types.

    You can read more about FreshMvvm here.

    Thanks for clearing but I have been looking into FreshMvvm these days and I found it quite interesting. I will give it a try. Just my curiosity and ignorance what do you mean by 'Xamarin Traditional' ? do you mean that xamarin androd or xamarin ios separately?

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @batmaci - yes he meant Xamarin.iOS and Xamarin.Android as traditional. I call it native, others by its full name. I don't think the community has really settled on what to call it from an XF perspective. :)

    The people just doing Xamarin Native :) only call it Xamarin because that is all Xamarin ever used to be.

  • GuyProvostGuyProvost CAMember ✭✭✭

    So, let's say I'm looking for a mvvm fx and want to build an app without using XF, I can not use mvvmfresh cause it depends on XF ? So if one wants to do MVVM without XF, one can use MvvmCross or MvvmLight ?

  • NMackayNMackay GBInsider, University mod
    edited June 2016


    Well we use the same nuget MVVM Light pluggin in Xamarin Forms and our very large Enterprise WPF app (which uses Prism too). FreshMVVM as Michael says is focused on Forms but i'm not sure what your saying, if you want to run the same code on Windows desktop and mobile you need Forms. You could arguably share a PCL with viewmodels, model etc between a Xamarin app and a WPF app but in practice....we don't. There's no true magic bullet yet IMO although Forms has the potential to be it. MVVMCross/Prism/Caliburn etc work fine with other technologies like WPF.

  • GuyProvostGuyProvost CAMember ✭✭✭
    edited June 2016

    Thanks for the answer. I'll try to explain the position I'm in.

    What I'm looking for is a MVVM framework and not use XF! So here's the deal, feel free to educate me, I think I miss a few concepts here and there!

    I've tasted XF and found some parts of it really nice, but for complex apps, it's not there yet... To me! Dont get me wrong, XF is great! Our "complex" app we built using XF ended for us to create a lot of custom renderers. So it tend to minimize the advantages of the abstraction UI that XF is all about! Killing the advantage of XF.

    But..., and this is the big part of what I'm looking fro these days... I loved the fact that XF provided us with a good enough DI and that it is built with MVVM pattern in mind (bindings and commands). So for our next project, we will built the app with a PCL to share code and create the UI in each platform tools and paradigms... And I'm on the lookout for two things...

    1) How to do the DI! should I use a IoC container or am I better off doing the DI manually in order to abstract the method in the PCL and implement it in the platform project when needed ? Heck... can I even do the DI manually ? Looked for some clear samples in Xamarin docs, but beside the diagram that Xamarin offers, recommanding to use Interfaces in the PLC and implementation in the device specific in the "Sharing Code Options" in xamarin docs (https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/#Portable_Class_Libraries) I haven't seen anything to guide me. I know about TinyIoC and others IoC containers, but maybe it is overkill ? Anyway... Still looking.

    2) How to architecture the app ?... Should I give MVVM pattern a go on this next project and be assisted by a framework so I wont have to build the bindings and Commands... Something like MvvmCross ?

    When I looked at FreshMvvm, it wasn't even clear to me why on earth would someone "add" some Mvvm feature over what XF has to offer in this area. Kinda like I still dont get why some people (like you) add a Mvvm framework OVER what WPF offers out of the box! I guess I'm too newby in the MVVM world to actually get it!

    So to me FreshMvvm requires XF... And I dont want to use XF. Could one use XF for the MVVM features and DI without using it to build the UI ?

    Those are the questions... At times I think all these things gets so confusing that I may build my next project entirely in a platform specific way, without code sharing in mind!

    If you can shed a light on this, you are more then welcome!

    Educate me!

  • NMackayNMackay GBInsider, University mod
    edited June 2016

    "Kinda like I still dont get why some people (like you) add a Mvvm framework OVER what WPF offers out of the box!"

    That's hard to answer, comes from experience of working with these technologies. These frameworks just make your life easier, there's nothing to stop you hand rolling your own helpers/base classes, Forms does give you the tools (as does WPF) but these frameworks take away a LOT of tedious code.

    You really have to make your own judgement on it though.

  • GuyProvostGuyProvost CAMember ✭✭✭

    Thanks for the input, I'll try to get the knowledge first, I'll start a discussion on a dedicated thread!

  • EbenVenterEbenVenter AUUniversity ✭✭

    Jumping on this thread as it seems to be close to what I'm trying to work out on my learning curve.
    Ok frameworks add value - each one with it's own benefits and strengths. But then I came across James Montamagno's MVVMHelpers with the ObservableRangeCollection, BaseViewModel, etc.

    (1) I assume that's more an extension than a framework, suited for both native and XF apps?
    (2) Does it make sense to use MVVMHelpers with a framework like FreshMvvm or MVVMLight, or does that defeat each other's purpose?

  • zuckerthobenzuckerthoben USMember ✭✭

    I just looked at the MVVMHelpers Repo (https://github.com/jamesmontemagno/mvvm-helpers) and I wonder the same. Can I use this in a solution that contains WPF and Xamarin.Forms Projects and create shared ViewModels with the help of these Helpers?

    I am sure I can do that with MVVMCross and MVVM Light but this seems to be even more lightweight. IoC and DI is interesting but I will try to learn one thing at a time.
    Some sample solutions would be great to see.

    My educated guess is that you would not use the MVVMHelpers together with a full MVVM FX. The implementations seem redundant to me.

  • percepticonpercepticon USMember ✭✭

    @batmaci If I were you I wouldn't use MVVMCross. It's a huge codebase and if you run into a problem they aren't too friendly or helpful.

  • NMackayNMackay GBInsider, University mod

    I started in Forms with MVVM Light, it's a great little MVVM framework but it's not forms focused and doesn't have a navigation service implementation, as our apps got more complicated and larger we moved to Prism & Unity.

    Some great features are:

    • Great navigation scheme making it really easy to pass objects as navigation contexts etc between pages
    • Modularity, when an app gets big you can really benefit from separating out the app in modules (Finance, Procurement etc), helps for security too.
      *other nice features like IDestructible & IActiveAware for tabs etc

    • Auto wire view & viewmodel

    • Register pages for navigation based on Idiom
    • Great slack channel with lots of people to help
    • Actively supported on Github
    • It's used quite a lot by some people in Xamarin and recommend by Miquel (Evolve 2016)
    • Lastly, Brian is really helpful considering how busy he is and will get back if you email him

    I haven't tried FreshMVVM but heard good things about it, if your solely focusing on frames I think Prism or FreshMVVM would be a good way to go.

    If your developing a mix of native and Forms apps then maybe MVVM Light, Cross etc.

    At the end of the day, which ever framework makes your life easier is the right choice for you, it's hard to recommend a framework as requirements and personal preference drive peoples opinions a lot of the time.

  • WinterCloudWinterCloud GBMember ✭✭✭

    Thanks for those video links. @MichaelRidland
    Great help.

    Do you know if we have similar Prism videos for Xamarin Forms anywhere?


  • hinojosachapelhinojosachapel ESMember ✭✭


    Xamarin Evolve 2016 Prism Video, Slides and Sample Code

    The Xamarin Show
    Episode 10: Prism for Xamarin.Forms with Brian Lagunas

  • BrianLagunasBrianLagunas USInsider ✭✭✭✭

    @MichaelRidland said:
    -FreshMvvm works different to Prism in regards to Navigation in that you control over the Navigation while prism makes the decisions for you, so Prism is easier but less flexible.

    You should really know what you're talking about before making blanket statements that are in correct. I understand you are trying to push your framework, but don't try to do it by making false statements.

  • MichaelRidlandMichaelRidland AUInsider, University ✭✭✭

    @BrianLagunas I'm a little offended by accusation, there's nothing false or incorrect about my statement, it's actually spot on.

    We use Prism in a few projects which are simple, it's easy to use and doesn't require a big learning curve. I like the simplicity. I'm not sure how can can deny that Prism makes decisions on Navigation for you, it's all there.

    FreshMvvm approach is different in that the user has to define how they want they navigation to work and they have more control over it. We use this in the cases that we need to have more control over the navigation system.

    There's navigation scenario's that can be done in FreshMvvm that cannot be done in Prism but on the other side the way Prism infers navigation for you is nice.

    I'm not sure why you're so defensive? All frameworks have their differences.

  • BrianLagunasBrianLagunas USInsider ✭✭✭✭

    @MichaelRidland You're statement is not correct. While Prism does do it's best to figure out what you want to do automatically, it also allows you to override that behavior. Prism gives you plenty of extension points and interfaces to control the navigation exactly how you want it to behave. It is extremely flexible. I understand that there are difference in frameworks, and I am all about building a cohesive community made of up many options, but speaking about other projects as if they are fact when they are not does not reflect on you in a positive light. Normally this would not bother me, and I'm probably just in one of those "grumpy get off my lawn moods" today, but this isn't the first time I've seen you misrepresent other projects in a pubic forum so I had to say something.

  • MichaelRidlandMichaelRidland AUInsider, University ✭✭✭

    @BrianLagunas My comments are correct but I don't want to get into arguments on forums I don't have the time, so I'm going to agree with you and apologize.

  • BrianLagunasBrianLagunas USInsider ✭✭✭✭

    @MichaelRidland To be fair, I did overreact and should have contacted you directly instead of replying like I did. I apologize for that. It's just been one of those days.

Sign In or Register to comment.