FreshMvvm – A Mvvm Framework designed for Xamarin.Forms

Now available via Nuget FreshMvvm is a Mvvm framework that’s designed specifically for Xamarin.Forms. The reason I say it’s designed for Xamarin.Forms is because it plays on Xamarin.Forms strengths and fills in ONLY the missing parts. It has a requirement for Xamarin.Forms and therefore is smart and can do thing such as wiring up the BindingContext and Page events.

Some of the feature for FreshMvvm include:

  • PageModel to PageModel Navigation

  • Automatic wiring of BindingContext

  • Automatic wiring of Page events (eg appearing)

  • Basic methods on PageModel (init, reverseinit)

  • Built in IOC Container

  • PageModel Constructor Injection

  • Basic methods available in Model, like Alert

  • Built in Navigation containers for SimpleNavigation, Tabbed and MasterDetail

How does it compare to other Mvvm options?

  • It’s super light and super simple

  • It’s specifically designed for Xamarin.Forms, nothing else does this currently

  • Designed to be easy to learn and develop (great when your not ready for RxUI)

  • Uses a Convention over Configuration

The Story

I was part-way into a Xamarin Traditional application when Xamarin.Forms was released. I wanted to move the project onto Xamarin.Forms but on that project I was using MvvmCross. At that time MvvmCross had no support for Xamarin.Forms, so I had the option of 1) adapting MvvmCross, 2) finding an alternative or 3) rolling my own Mvvm. The best part about MvvmCross was it’s two-way databinding to the native iOS/Android controls but since Xamarin.Forms already had the Databinding builtin, that wasn’t useful and the size with MvvmCross was an overhead when I didn’t require it. I also wasn’t able to find an alternative that I could easily move to. So that I could keep it simple and flexible, I ended up rolling my own Mvvm.

It’s grown up from this post on rolling your own Mvvm for Xamarin.Forms. I try hard to keep the simplicity of rolling your own Mvvm for Xamarin.Forms.

It was never a plan to create a framework but after presenting my Mvvm solution at a few events, I found many people wanted it and seemed to be really interested in it. Also considering I’ve been using this Framework in all my projects from the start of Xamarin.Forms I know that it works, so I created FreshMvvm and that’s how it was born.


This Framework, while simple, is also powerful and uses a Convention over Configuration style.

Note Different to standard naming conventions, FreshMvvm uses Page and PageModel instead of View and ViewModel, this is inline with Xamarin.Forms using Pages

  • A Page must have a corresponding PageModel, with naming important so a QuotePageModel must have a QuotePage The BindingContext on the page will be automatically set with the Model

  • A PageModel can have a Init method that takes a object

  • A PageModel can have a ReverseInit method that also take a object and is called when a model is poped with a object

  • PageModel can have dependancies automatically injected into the Constructor


The Primary form of Navigation in FreshMvvm is PageModel to PageModel, this essentially means our views have no idea of Navigation.

So to Navigate between PageModels use:

The engine for Navigation in FreshMvvm is done via a simple interface, with methods for Push and Pop. Essentially these methods can control the Navigation of the application in any way they like.

This is what you as a consumer will need to implement, and then register in the IOC Container.

Within the PushPage and PopPage you can do any type of navigation that you like, this can from a simple navigation to a advanced nested navigation.

The Framework contains some built in Navigation containers for the different types of Navigation.

Basic Navigation – Built In

Master Detail – Built In

Tabbed Navigation – Built In

Implementing Custom Navigation

It’s possible to setup any type of Navigation by implementing IFreshNavigationService.There’s a sample of this in Sample Application named CustomImplementedNav.cs.

Inversion of Control (IOC)

So that you don’t need to include your own IOC container, FreshMvvm comes with a IOC container built in. It’s using TinyIOC underneith, but with different naming to avoid conflicts.

To Register services in the container use Register:

To obtain a service use Resolve:

*This is also what drives constructor injection.

PageModel – Constructor Injection

When PageModels are pushed services that are in the IOC container can be pushed into the Constructor.

PageModel Important Methods

The CoreMethods

Each PageModel has a property called ‘CoreMethods’ which is automatically filled when a PageModel is pushed, it’s the basic functions that most apps need like Alerts, Pushing, Poping etc.


Sample PageModel

10 Responses

  1. Hi Michael. Looks like a great framework. Do you have a small sample project available that demonstrates the framework?

  2. Hi Michael,

    Does FreshMVVM duplicate the functionality of Xamarin.Forms MVVM and Dependency Service? If not, when to use one or the other?

    Thanks for your freat work and more power.



    1. Hi Jose

      FreshMvvm doesn’t duplicate any Xamarin.Forms functionality, it only fills in the missing pieces of Mvvm for Xamarin.Forms and puts it into a Framework.


    1. Hi, in this case you wouldn’t use a FreshTabbedNavigationContainer, just a normal Xamarin.Forms.TabbedPage.

      If you want it all to work inside the PageModelPushing you’ll need to implement a custom navigation container.

      That container can have both the Navigation Pages.

  3. Michael,
    Any plans to support UWP? I tried to add it to a new app I\\\\\\\’m working on and I get the following error:
    “FreshMvvm 0.0.6 is not compatible with UAP,Version=v10.0 (win10-x64-aot).”


    1. Yes it will definitely work with UWP. I’m actually not sure why this isn’t working. I will need to look into it.

Leave a Reply