If you don't have existing code, then just use the Ninja Coder Visual Studio Extension for MVVMCross. If you have existing code already (ie: running an Xamarin android that you want to port to MvvmCross, then follow these steps:
Creating New MvvmCross Project
Setting up the Core Project
- Create a new PCL
- select .NET Framework 4.5, Windows 8, Windows Phone Silverlight 8, Windows Phone 8.1, Xamarin.Android and Xamarin.iOS - this will ensure that the PCL is in Profile259.
- Install the nuget package into this Core Project:
Install-Package MvvmCross.HotTuna.MvvmCrossLibraries
- Create an App.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cirrious.CrossCore.Plugins;
namespace Something.Core
{
public class App : Cirrious.MvvmCross.ViewModels.MvxApplication
{
public override void LoadPlugins(IMvxPluginManager pluginManager)
{
base.LoadPlugins(pluginManager);
}
public override void Initialize()
{
RegisterAppStart<ViewModels.SomeStartingViewModel>();
}
}
}
Creating New Android Project
- Open your Xamarin Android projct
Install-Package MvvmCross.HotTuna.MvvmCrossLibraries
-
Download the Android Resource file here
-
Add the Android Resource file to the /Resources/Values folder
-
Set it's BuildAction set to AndroidResource
-
Create a new Setup.cs file
using Android.Content;
using Cirrious.MvvmCross.Droid.Platform;
using Cirrious.MvvmCross.ViewModels;
using Something.Core;
namespace Something.Droid
{
public class Setup : MvxAndroidSetup
{
public Setup(Context applicationContext)
: base(applicationContext)
{
}
protected override IMvxApplication CreateApp()
{
return new App();
}
}
}
Unit Test Project
Install-Package MvvmCross.HotTuna.MvvmCrossLibraries
Install-Package MvvmCross.HotTuna.Tests -Version 3.2.1