Skip to main content

Mvvmcross

How to setup Ninject as the default DI container in MvvmCross?

·3 mins

When you build a multi-platform application in .NET, especially for the mobile, you typically choose between two approaches. One is to code the shared UI layer commonly with Xamarin.Forms (you will still need to have some parts to be placed in platform projects, like custom renderers or providers). The second is to put the entire UI code in platform-specific projects. In this approach you can use the full power of each platform features (like fragments on Android). Both solutions allow for sharing common business logic between all the platforms. On the other hand full implementation of MVVM pattern in the second approach can be tricky and time consuming. The solution is to use 3rd party library; and here comes the MvvmCross. It covers many more areas than the pure MVVM pattern:

Why does MVVMCross view model initialize twice on iOS?

·2 mins

Working on a bug fix in MVVMCross-based mobile application I noticed a strange behavior. The navigation to other view model I put in async Init<TInit>(TInit parameters) which as executed on the first view model in my app was running twice. After a short debugging session it turned out that MvxViewModel<TInit> Init() is called from the view controllers ViewDidLoad() method. Obviously there was something I was missing in terms of ViewDidLoad() semantics.