2. Sean’s Guff
Formerly CIO at Catalyst Risk Management
Currently unemployed
Personal shareware site at
www.sourceitsoftware.com
Blog at
sourceitsoftware.blogspot.com
@seanrcross
sean@sourceitsoftware.com
3. To cover
•What are we trying to achieve
•Example
•Theory (boring!)
•Getting started with MvvmCross
•Plugins
•Platform specific stuff
•Summary
•Links
9. Xamarin
•Commercial products for C# development for non-Windows platforms
•Xamarin.Android
•Xamarin.iOS
•Xamarin.Mac
•Need business edition for VS integration @ $999 US each
11. 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 3rd party PCLs available (HttpClient, Imaging, JSON…)
22. Using MvvmCross
•Hard
-
download from github, compile, include references etc
•Easy
-
Nuget; look for MvvmCross Hot Tuna Starter Pack, and plugins
•Real Easy
-
NinjaCoder
25. Plugins
•Convenient way to access platform functionality
•Use NinjaCoder or Nuget to add plugins
•Includes Accelerometer, Email, Files, Location, Messaging, Sqlite
•3rd party plugins available as well.
•Consume plugins using Dependency Injection or Service locator
27. Platform specific code
•Describe functionality using an interface in .Core
•Create platform specific implementation in .xxxx
•Register implementation on app startup
◦ Mvx.RegisterSingleton<ISettingsPersistance>(new SettingsPersistanceWPF());
◦ Mvx.RegisterType<IGetRemoteData, RemoteDataWpf>();
•Consume plugins using Dependancy Injection or Service locator
• persistance = Mvx.Resolve<ISettingsPersistance>();
29. 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
Model-View-ViewModel (MVVM) pattern splits the User Interface code into 3 conceptual parts - Model, View and ViewModel Model is a set of classes representing the data coming from the services or the database. View is the code corresponding to the visual representation of the data the way it is seen and interacted with by the user. ViewModel serves as the glue between the View and the Model. It wraps the data from the Model and makes it friendly for being presented and modified by the view. ViewModel also controls the View's interactions with the rest of the application (including any other Views).
Any object that you want to bind in the View (e.g. the ViewModel, and any objects that the VM exposes) need to implement INotifyPropertyChanged. The base VM object normally implements a RaisePropertyChanged method that you call whenever you want to notify the View that a property has changed.Text fields etc on the View are bound to properties on the ViewModelButtons and actions are bound to ICommand propertiesLists are bound to a collection implementing INotifyCollectionChanged , oftenObservableCollection
What is says on the boxSpecifically designed for cross platform