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
www.sourceitsoftware....
To cover
•What are we trying to achieve
•Example
•Theory (boring!)
•Getting started with MvvmCross
•Plugins
•Platform spec...
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...
Xamarin Demo
Portable Class Libraries
•Create a single library that can be used by multiple .net frameworks
•Allows access only to func...
.net x.x

Silverlight

Portable Class
Library
Shared
functionality
.net x.x

Silverlight

Portable Class
Library
Shared
functionality

Windows Store
.net x.x

Silverlight

Portable Class
Library
Shared
functionality

Windows Store

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

•INotifyCollectionCh...
Mvvm: Binding
XAML
<StackPanel>
<TextBox Text="{Binding Hello, Mode=TwoWay}" />
<TextBlock Text="{Binding Hello}" />
<Button Content="Cl...
MvvmCross
•Cross Platform MVVM Development Framework
•Free, open source
•Supports
•
•
•
•
•
•

WP7,8
WPF
WinRT
Xamarin.And...
MvvmCross Architecture
Using MvvmCross
•Hard

-

download from github, compile, include references etc

•Easy

-

Nuget; look for MvvmCross Hot T...
Getting started - Nuget
Getting started - NinjaCoder
Plugins
•Convenient way to access platform functionality
•Use NinjaCoder or Nuget to add plugins
•Includes Accelerometer, ...
Plugins Demo
Platform specific code
•Describe functionality using an interface in .Core
•Create platform specific implementation in .xx...
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
•Mv...
Links - MvvmCross
Stuart Lodge - MvvmCross Author
•Twitter

@slodge

•Blog

http://slodge.blogspot.co.uk/

•Videos

http:/...
Links - Xamarin
•Website -

http://www.xamarin.com/

•Samples -

https://github.com/xamarin

•Mobile library - https://git...
Links – Ninja Coder
•Adrian Sudbury – Ninja Coder Author
•Twitter

@asudbury

•Blog

http://adriansudbury.blogspot.co.uk/
...
Links - Other
http://www.hanselman.com/blog/CrossPlatformPortableClassLibrariesWithNETAreHappening.aspx
http://sourceitsof...
Credits
Mvvm Images from http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM
Questions
•Answers not guaranteed
Hot tuna - from Sean Cross
Upcoming SlideShare
Loading in …5
×

Hot tuna - from Sean Cross

2,986 views

Published on

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,986
On SlideShare
0
From Embeds
0
Number of Embeds
2,023
Actions
Shares
0
Downloads
22
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Phone gap
  • 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&apos;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
  • Hot tuna - from Sean Cross

    1. 1. Hot Tuna CROSS PLATFORM DEVELOPMENT WITH .NET, XAMARIN AND MVVMCROSS
    2. 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. 3. To cover •What are we trying to achieve •Example •Theory (boring!) •Getting started with MvvmCross •Plugins •Platform specific stuff •Summary •Links
    4. 4. The holy grail
    5. 5. What is achievable
    6. 6. Example – Lions Official (sorry)
    7. 7. The pieces •.net (duh) •Xamarin (iOS, Android, Mac) •Portable Class Libraries •MvvmCross
    8. 8. 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
    9. 9. Xamarin Demo
    10. 10. 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…)
    11. 11. .net x.x Silverlight Portable Class Library Shared functionality
    12. 12. .net x.x Silverlight Portable Class Library Shared functionality Windows Store
    13. 13. .net x.x Silverlight Portable Class Library Shared functionality Windows Store Xamarin.XXXX
    14. 14. PCL Demo Easy-peasy, lemon squeezy It’s hard to find a good image of a class library
    15. 15. Mvvm: Model – View Model - Model
    16. 16. Mvvm: Key interfaces •INotifyPropertyChanged • RaisePropertyChanged(() => PropertyName ); •ICommand •INotifyCollectionChanged (or ObservableCollection)
    17. 17. Mvvm: Binding
    18. 18. XAML <StackPanel> <TextBox Text="{Binding Hello, Mode=TwoWay}" /> <TextBlock Text="{Binding Hello}" /> <Button Content="Click Me" Command="{Binding MyCommand}" /> <Button Content="Go Second" Command="{Binding GoSecondCommand}" /> </StackPanel> Code 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<SecondViewModel>(); } }
    19. 19. MvvmCross •Cross Platform MVVM Development Framework •Free, open source •Supports • • • • • • WP7,8 WPF WinRT Xamarin.Android Xamarin.iOS Xamarin.Mac •AKA Mvx
    20. 20. MvvmCross Architecture
    21. 21. Using MvvmCross •Hard - download from github, compile, include references etc •Easy - Nuget; look for MvvmCross Hot Tuna Starter Pack, and plugins •Real Easy - NinjaCoder
    22. 22. Getting started - Nuget
    23. 23. Getting started - NinjaCoder
    24. 24. 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
    25. 25. Plugins Demo
    26. 26. 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>();
    27. 27. Platform specific example •Here is one that I prepared earlier
    28. 28. 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
    29. 29. Links - MvvmCross Stuart Lodge - MvvmCross Author •Twitter @slodge •Blog http://slodge.blogspot.co.uk/ •Videos http://www.youtube.com/user/MrHollywoof?feature=watch •List of tutorial videos http://mvvmcross.wordpress.com/ •Repository https://github.com/slodge/MvvmCross
    30. 30. Links - Xamarin •Website - http://www.xamarin.com/ •Samples - https://github.com/xamarin •Mobile library - https://github.com/xamarin/Xamarin.Mobile
    31. 31. Links – Ninja Coder •Adrian Sudbury – Ninja Coder Author •Twitter @asudbury •Blog http://adriansudbury.blogspot.co.uk/ •Ninja Coder http://visualstudiogallery.msdn.microsoft.com/618b51f0-6de8-4f85-95ce-a50c658c7767
    32. 32. Links - Other http://www.hanselman.com/blog/CrossPlatformPortableClassLibrariesWithNETAreHappening.aspx http://sourceitsoftware.blogspot.co.nz/
    33. 33. Credits Mvvm Images from http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM
    34. 34. Questions •Answers not guaranteed

    ×