Xamarin.Forms & Microsoft Unity 4.0.1
Xamarin.Forms has built-in features for dependency injection but there are gaps. When it comes to the traditional containers for services and view models, you will find many projects will use Autofac, Ninject or some other libraries. With the version of 4.0.1 in 2015, which addressed complaints of containers exceptions, I have preferred Microsoft’s Unity framework for several reasons. Unity allows me to lazy load, as needed, objects into the container as the application is running. I can also determine the lifespan of the object loaded. Autofac used to have lazy loading but that feature has been deprecated and now all objects must be defined prior to building the container. One more feature is a must and that is the ability to query the container objects like any other collection.
I wrapped the features I liked in Unity into an Injection Manager class in my project and provided generic methods to access services and view models as needed. The wrapper now provides a way for me to load resources only as I need them and provides a communication framework without delegates and events which can cause memory issues. Examples of the this code and its use in a project can be found on my github site.