Hot Tuna CROSS PLATFORM DEVELOPMENT WITH.NET, XAMARIN AND MVVMCROSS
Sean’s Guff Formerly CIO at Catalyst Risk Management Currently unemployed Personal shareware site at Blog at sourceitsoftware.blogspot.com
To cover What are we trying to achieve Example Theory (boring!) Getting started with MvvmCross Plugins Platform specific stuff Summary Links
The holy grail
What is achievable
Example – Lions Official (sorry)
The pieces. net (duh) Xamarin (iOS, Android, Mac) Portable Class Libraries MvvmCross
Xamarin Commercial products for C# development for non-Windows platforms Xamarin.Android Xamarin.iOS Xamarin.Mac Need business edition for VS $999 US each
Xamarin Demo
Portable Class Libraries Create a single library that can be used by multiple.net frameworks Allows access only to functionality shared by all selected frameworks Does some nifty namespace mapping Makes cross platform development much easier Microsoft and 3 rd party PCLs available (HttpClient, Imaging, JSON…)
.net x.x Portable Class Library Shared functionality Silverlight
.net x.x Windows Store Portable Class Library Shared functionality Silverlight
.net x.x Windows Store Portable Class Library Shared functionality Silverlight Xamarin.XXXX
PCL Demo Easy-peasy, lemon squeezy It’s hard to find a good image of a class library
Mvvm: Model – View Model - Model
Mvvm: Key interfaces INotifyPropertyChanged RaisePropertyChanged(() => PropertyName ); ICommand INotifyCollectionChanged (or ObservableCollection)
Mvvm: Binding
XAML Code <Button Content="Go Second" Command="{Binding GoSecondCommand}" /> public class FirstViewModel : MvxViewModel { private string _hello = "Hello MvvmCross"; public string Hello { get { return _hello; } set { _hello = value; RaisePropertyChanged(() => Hello); } } public System.Windows.Input.ICommand MyCommand { get { return new Cirrious.MvvmCross.ViewModels.MvxCommand(DoMyCommand); } private void DoMyCommand() { Hello = Hello + " World"; } public System.Windows.Input.ICommand GoSecondCommand { get { return new Cirrious.MvvmCross.ViewModels.MvxCommand(DoGoSecond); } private void DoGoSecond() { ShowViewModel (); }
MvvmCross Cross Platform MVVM Development Framework Free, open source Supports WP7,8 WPF WinRT Xamarin.Android Xamarin.iOS Xamarin.Mac AKA Mvx
MvvmCross Architecture
Using MvvmCross Hard -download from github, compile, include references etc Easy-Nuget; look for MvvmCross Hot Tuna Starter Pack, and plugins Real Easy-NinjaCoder
Getting started - Nuget
Getting started - NinjaCoder
Plugins Convenient way to access platform functionality Use NinjaCoder or Nuget to add plugins Includes Accelerometer, , Files, Location, Messaging, Sqlite 3 rd party plugins available as well. Consume plugins using Dependency Injection or Service locator
Plugins Demo
Platform specific code Describe functionality using an interface in.Core Create platform specific implementation in.xxxx Register implementation on app startup ◦Mvx.RegisterSingleton (new SettingsPersistanceWPF()); ◦Mvx.RegisterType (); Consume plugins using Dependancy Injection or Service locator persistance = Mvx.Resolve ();
Platform specific example Here is one that I prepared earlier
Summary PCLs let you use easily share code across multiple platforms Xamarin lets you use C# on Android, iOS and Mac MvvmCross wraps it all up to make it easy Shared PCL that holds most functionality Platform specific apps for views and dependant code Plugins let you easily add functionality in a cross platform friendly way Do your own platform dependant stuff using interfaces and IoC/Dependancy Injection
Links - MvvmCross Stuart Lodge - MvvmCross Author Blog Videos List of tutorial videos Repository
Links - Xamarin Website - Samples - Mobile library -
Links – Ninja Coder Adrian Sudbury – Ninja Coder Author Blog Ninja Coder
Links - Other
Credits Mvvm Images from
Questions Answers not guaranteed