Cross platform mobile development with visual studio and xamarin

  • 2,204 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,204
On Slideshare
0
From Embeds
0
Number of Embeds
13

Actions

Shares
Downloads
13
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Cross platform mobile development with Visual Studio and Xamarin: Architecture and code reuse Ibon Landa Plain Concepts
  • 2.   
  • 3. Native Development iOS Objective C Xcode Windows Phone C#/Visual Basic/F# Visual Studio Android Java Eclipse IntelliJ
  • 4. Using the platform native tools Xcode ADT Visual Studio + + - ✗
  • 5. Build and debug iOS applications on a Windows computer using the Visual Studio IDE Windows Windows 7 or higher. Visual Studio 2010 Professional or higher. Xamarin’s plug-in for Visual Studio. MAC A Macintosh running OS X Lion or higher (although we recommend the latest version). Xamarin iOS SDK. Apple’s Xcode IDE and iOS SDK (we recommend the latest version from the App Store). Xamarin.iOS on Windows
  • 6. Xamarin.iOS on Windows
  • 7. Use PCLs Use View Models to reuse presentation code Heavy use of dependency injection Allows different implementations for different platforms Improving Code Reuse in 3 easy ways
  • 8. 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…) Portable Class Libraries
  • 9. Shared Core
  • 10. Maximizing code reuse How to display information What information to display Flow of interaction Data objects Business logic Etc. Model View Model View Device-specific Portable codeReferences Databinds
  • 11. UI Application Logic Out of the box approach View ViewModel Model Model-View-ViewModel (MVVM)
  • 12. Cross Platform MVVM Development Framework Free, open source Supports WP7,8 WPF WinRT Xamarin.Android Xamarin.iOS Xamarin.Mac AKA Mvx MvvmCross
  • 13. XAML Code <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> 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>(); } }
  • 14. MvvmCross Architecture
  • 15. 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 MvvmCross Plugins
  • 16. 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>(); Platform specific code
  • 17. Architecture overview
  • 18. 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 Summary
  • 19. Thanks!