SlideShare une entreprise Scribd logo
1  sur  59
@slodge




  Cross Platform Mobile
C#, Mvvm and DataBinding
          WP7
         Android
         iPhone
           iPad
          Win 8
@slodge



@slodge
@slodge



http://bit.ly/mvvmcross
@slodge



                Coming up…
•   C# Cross Platform
•   An Mvvm Introduction
•   Some Code: TwitterSearch
•   Some Extras
•   Q&A
@slodge




Mobile
 C#
@slodge



                   Why C#?
• You already have:
   – skills
   – tools
   – code
• “low level”
   – compiles
   – testable
   – quick
• Enables native look and feel on all platforms
• Generics, Linq, Async and the future…
@slodge



         What you need – WP7:


•   A Windows 7 PC
•   Free Tools or better!
•   AppHub account $99
•   A phone sometimes helps…
@slodge



        What you need - Android:


•   Windows PC or a Mac
•   Free Tools
•   Play account $25
•   A phone really helps…
•   Mono 4 Android $400
@slodge



           What you need - iOS:


•   An Intel-based Mac
•   Account-Linked Tools
•   iOS Account $99
•   A phone often helps…
•   MonoTouch - $400
@slodge



Getting Started Links…
@slodge




MVVM
@slodge



                Mvvm Basics


           get/set
           Properties




                           ViewModel
           call Commands




                            ViewModel




                                                            Model
View




                              ViewModel
                                          Whatever C# you




                                                             Model
 View




                                          like!




                                                              Model
   View




          notify changes
          some messaging
@slodge



         MVVM Technical Details
•   Properties
•   INotifyPropertyChanged
•   INotifyCollectionChanged
•   Data Binding
•   IValueConverter
•   ICommand
•   UI Thread
@slodge



               Mvvm Benefits
• The “normal” reasons:
  – Separation of concerns
  – Designability (Blendability)
  – Testability


• The MvvmCross reason:
  – Cross platform code reuse
@slodge



            Mvvm Cross Platform

                get/set
                Properties




                                ViewModel
                call Commands




                                 ViewModel




                                                                  Model
  View




                                   ViewModel
                                                Whatever C# you




                                                                   Model
   View




                                                like!




                                                                    Model
     View




               notify changes
               some messaging




Platform Specific                              Shared
@slodge



Some longer introductions…
@slodge




Twitter
Search
@slodge



         What we want to build…

Home Page:            Result Page:
@slodge




The “core” code
@slodge



The Model and Service
@slodge



HomeViewModel
@slodge



TwitterViewModel
@slodge



               Navigation
• The HomeViewModel calls:




• Which means the TwitterViewModel gets
  created with:
@slodge




The clients
@slodge



Some Unit Tests
@slodge



A Console App
@slodge



A WP7 App
@slodge



An Android App
@slodge



iPhone App
@slodge



iPad App
@slodge



Windows 8 Metro App
@slodge




Inside…
@slodge



           Inside WP7 App…




• No C#, just XAML with {Binding}
• Binding syntax includes:
        {Binding Path, Converter=Converter,
      ConverterParameter=Parameter, Mode=Mode,
              FallbackValue=Fallback}
@slodge



         Inside Android App…
• No C#, just xml
  with MvxBind
  attributes
• MvxBind syntax is
  JSON based on
  XAML structure.
@slodge



       Binding – Xaml versus Mvx
WP7:
 Text=‚{Binding SearchText,Mode=TwoWay}‛


Android:
         local:MvxBind=‚{‘Text’:
 {‘Path’:’SearchText’,’Mode’:’TwoWay’}}‛
@slodge



       Binding – Xaml versus Mvx
WP7:
              Text=‚{Binding
   Timestamp,Converter={StaticResource
                TimeAgo}}‛

Android:
         local:MvxBind=‚{‘Text’:
{‘Path’:’Timestamp’,Converter’:’TimeAgo’}
                    }‛
@slodge



           Inside iPhone App
• UI is drawn in XML using Xcode
• XIB is linked to C# classes using MonoTouch
• Binding is declared in C# using JSON
@slodge
@slodge



              Inside iPad App
• The iPad App is actually the iPhone App –
  “Universal”
• But the UI is different – take advantage of the
  larger screen.
• Achieved in code: IMvxTouchViewPresenter
@slodge



Inside Windows 8 Metro App…
@slodge



   Inside Windows 8 Metro App…
It’s like WP7….
• No C#, just XAML with {Binding}


• ValueConverters are used in Bindings
• Lists are filled using ItemsSource

• BUT: Navigation is achieved through code – not
  Xaml Uri’s
@slodge



     Inside Windows 8 Metro App
Warnings:
• MvvmCross WinRT implementation
  is “first cut”
   – e.g. differences in ViewModel lifecycle
• Under-the-hood Win8
  implementation is native code –
  there are big differences.
   – differences in XAML
   – differences in .Net/C#
• Everything is async.
@slodge



   Inside Windows 8 Metro App…
• Beyond the warnings – look at the numbers!
@slodge




Recap
@slodge



        TwitterSearch recap…
• Shared C# Core
  – ViewModels
  – Models
  – Services
  – Converters
  – Tests

• UIs are “mostly XML/JSON”
@slodge




Some
Extras
@slodge
@slodge



      Panoramas, Pivots and Tabs
• Tabbed navigation is another common metaphor
  across phones and across ipads too.
• Generally speaking think of each “tab” as a sub-
  ViewModel.
@slodge



                 Jump Lists
• Use grouped list on
  each viewmodel…
• Each platform then
  works out its own
  format
@slodge



          Dependency Injection
• Useful for testing
• Essential for injecting platform specific services –
  e.g:
   – Camera capture
   – GPS services
   – NFC
• MvvmCross wraps OpenNetCF DI – adds some
  extension methods:
   – RegisterServiceInstance<TService>(instance)
   – RegisterServiceType<TService, TServiceType>()
   – GetService<TService>()
@slodge



                Native Types
• Sometimes #define is necessary…
• Personally, I try to use interfaces and DI
  wherever possible.
@slodge



                       i18n
• Choices:
  – Each platform has their own localisation format
    available.
  – Xamarin are supporting .resx files…
  – MvvmCross provides a .json file mechanism
  – Or write your own
@slodge



               Blendability
• Limited support available right now.
• It’s relatively easy to integrate your own
  design time ViewModelLocator with design
  time data…
@slodge



                 Problems?
• WinRT – issues…
• Xcode designer - OMG
• iOS development and debugging is most
  painful
• Some compiler differences – JIT
• Multiple “core” project files annoying – and
  breaks refactoring
• MvvmCross still changing
@slodge




 That’s
all folks
@slodge



             That’s all folks…
Hopefully we covered:
• C# Cross Platform
• An Mvvm Introduction
• Some Code: TwitterSearch
• Some Extras

There might be time for:
• Q&A
@slodge



@slodge
@slodge



http://bit.ly/mvvmcross
@slodge



Alternatives: http://bit.ly/rrnLDT

Contenu connexe

Tendances

General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
Spike Brehm
 
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Philipp Burgmer
 
Web, Native iOS and Native Android with One Ember.js App
Web, Native iOS and Native Android with One Ember.js AppWeb, Native iOS and Native Android with One Ember.js App
Web, Native iOS and Native Android with One Ember.js App
FITC
 
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MBNodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
David Wesst
 

Tendances (20)

General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
 
Tutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSTutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJS
 
MVP Mix 2015 Leveraging MVVM on all Platforms
MVP Mix 2015  Leveraging MVVM on all PlatformsMVP Mix 2015  Leveraging MVVM on all Platforms
MVP Mix 2015 Leveraging MVVM on all Platforms
 
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
 
Modern Web Development in 2015
Modern Web Development in 2015Modern Web Development in 2015
Modern Web Development in 2015
 
PLASTIC 2011: "Enterprise JavaScript with Jangaroo"
PLASTIC 2011: "Enterprise JavaScript with Jangaroo"PLASTIC 2011: "Enterprise JavaScript with Jangaroo"
PLASTIC 2011: "Enterprise JavaScript with Jangaroo"
 
Web, Native iOS and Native Android with One Ember.js App
Web, Native iOS and Native Android with One Ember.js AppWeb, Native iOS and Native Android with One Ember.js App
Web, Native iOS and Native Android with One Ember.js App
 
Top java script frameworks ppt
Top java script frameworks pptTop java script frameworks ppt
Top java script frameworks ppt
 
Phonegap Day 2016: Ember/JS & Hybrid Apps Tips
Phonegap Day 2016: Ember/JS & Hybrid Apps TipsPhonegap Day 2016: Ember/JS & Hybrid Apps Tips
Phonegap Day 2016: Ember/JS & Hybrid Apps Tips
 
The 5 Layers of Web Accessibility
The 5 Layers of Web AccessibilityThe 5 Layers of Web Accessibility
The 5 Layers of Web Accessibility
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MBNodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
 
MEAN Stack
MEAN Stack MEAN Stack
MEAN Stack
 
B4UConference_Sexy Angular Stack
B4UConference_Sexy Angular StackB4UConference_Sexy Angular Stack
B4UConference_Sexy Angular Stack
 
WebAssembly WASM Introduction Presentation
WebAssembly WASM Introduction PresentationWebAssembly WASM Introduction Presentation
WebAssembly WASM Introduction Presentation
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
Anton Sakharov: The risks you take when develop cross-platform apps using HT...
 Anton Sakharov: The risks you take when develop cross-platform apps using HT... Anton Sakharov: The risks you take when develop cross-platform apps using HT...
Anton Sakharov: The risks you take when develop cross-platform apps using HT...
 
DevDay 2018 - Blazor
DevDay 2018 - BlazorDevDay 2018 - Blazor
DevDay 2018 - Blazor
 

Similaire à Dev evening - MonoTouch, MonoDroid, Mvvm MvvmCross and databinding

MvvmCross Introduction
MvvmCross IntroductionMvvmCross Introduction
MvvmCross Introduction
Stuart Lodge
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
Gill Cleeren
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
Goutam Dey
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
Spike Brehm
 
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
tilejak773
 

Similaire à Dev evening - MonoTouch, MonoDroid, Mvvm MvvmCross and databinding (20)

Wpug mvvm and data binding
Wpug   mvvm and data bindingWpug   mvvm and data binding
Wpug mvvm and data binding
 
MvvmCross Introduction
MvvmCross IntroductionMvvmCross Introduction
MvvmCross Introduction
 
MvvmCross Seminar
MvvmCross SeminarMvvmCross Seminar
MvvmCross Seminar
 
Angular js
Angular jsAngular js
Angular js
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
C# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform developmentC# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform development
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Web Unleashed Toronto 2015: Hybrid Mobile Apps with Ember.js
Web Unleashed Toronto 2015: Hybrid Mobile Apps with Ember.jsWeb Unleashed Toronto 2015: Hybrid Mobile Apps with Ember.js
Web Unleashed Toronto 2015: Hybrid Mobile Apps with Ember.js
 
Cross Platform Development in C# (DDDNorth 2013)
Cross Platform Development in C# (DDDNorth 2013)Cross Platform Development in C# (DDDNorth 2013)
Cross Platform Development in C# (DDDNorth 2013)
 
Cross platform Xamarin Apps With MVVM
Cross platform Xamarin Apps With MVVMCross platform Xamarin Apps With MVVM
Cross platform Xamarin Apps With MVVM
 
Ember Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberEmber Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with Ember
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
 
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
 
Angular js
Angular jsAngular js
Angular js
 
Make it compatible
Make it compatibleMake it compatible
Make it compatible
 

Plus de Stuart Lodge

Hot tuna - from Sean Cross
Hot tuna - from Sean CrossHot tuna - from Sean Cross
Hot tuna - from Sean Cross
Stuart Lodge
 
Ui testing for Windows Phone
Ui testing for Windows PhoneUi testing for Windows Phone
Ui testing for Windows Phone
Stuart Lodge
 
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeUk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Stuart Lodge
 

Plus de Stuart Lodge (15)

Hot tuna - from Sean Cross
Hot tuna - from Sean CrossHot tuna - from Sean Cross
Hot tuna - from Sean Cross
 
Helping the Lions Roar
Helping the Lions RoarHelping the Lions Roar
Helping the Lions Roar
 
Wpug meeting - wp to win8 experiences
Wpug meeting - wp to win8 experiencesWpug meeting - wp to win8 experiences
Wpug meeting - wp to win8 experiences
 
AlphaLabs - Node Garden with Speech
AlphaLabs - Node Garden with Speech AlphaLabs - Node Garden with Speech
AlphaLabs - Node Garden with Speech
 
About Cirrious ltd
About Cirrious ltdAbout Cirrious ltd
About Cirrious ltd
 
C# Client to Cloud
C# Client to CloudC# Client to Cloud
C# Client to Cloud
 
How to make a pig udf
How to make a pig udfHow to make a pig udf
How to make a pig udf
 
C# - Azure, WP7, MonoTouch and Mono for Android (MonoDroid)
C# - Azure, WP7, MonoTouch and Mono for Android (MonoDroid)C# - Azure, WP7, MonoTouch and Mono for Android (MonoDroid)
C# - Azure, WP7, MonoTouch and Mono for Android (MonoDroid)
 
Mvvm cross – going portable
Mvvm cross – going portableMvvm cross – going portable
Mvvm cross – going portable
 
Ui testing for Windows Phone
Ui testing for Windows PhoneUi testing for Windows Phone
Ui testing for Windows Phone
 
How To use Map Blogs
How To use Map BlogsHow To use Map Blogs
How To use Map Blogs
 
Uk Nuke Rpx Authentication For Dot Net Nuke
Uk Nuke Rpx Authentication For Dot Net NukeUk Nuke Rpx Authentication For Dot Net Nuke
Uk Nuke Rpx Authentication For Dot Net Nuke
 
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeUk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
 
UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Dev evening - MonoTouch, MonoDroid, Mvvm MvvmCross and databinding

  • 1. @slodge Cross Platform Mobile C#, Mvvm and DataBinding WP7 Android iPhone iPad Win 8
  • 4. @slodge Coming up… • C# Cross Platform • An Mvvm Introduction • Some Code: TwitterSearch • Some Extras • Q&A
  • 6. @slodge Why C#? • You already have: – skills – tools – code • “low level” – compiles – testable – quick • Enables native look and feel on all platforms • Generics, Linq, Async and the future…
  • 7. @slodge What you need – WP7: • A Windows 7 PC • Free Tools or better! • AppHub account $99 • A phone sometimes helps…
  • 8. @slodge What you need - Android: • Windows PC or a Mac • Free Tools • Play account $25 • A phone really helps… • Mono 4 Android $400
  • 9. @slodge What you need - iOS: • An Intel-based Mac • Account-Linked Tools • iOS Account $99 • A phone often helps… • MonoTouch - $400
  • 12. @slodge Mvvm Basics get/set Properties ViewModel call Commands ViewModel Model View ViewModel Whatever C# you Model View like! Model View notify changes some messaging
  • 13. @slodge MVVM Technical Details • Properties • INotifyPropertyChanged • INotifyCollectionChanged • Data Binding • IValueConverter • ICommand • UI Thread
  • 14. @slodge Mvvm Benefits • The “normal” reasons: – Separation of concerns – Designability (Blendability) – Testability • The MvvmCross reason: – Cross platform code reuse
  • 15. @slodge Mvvm Cross Platform get/set Properties ViewModel call Commands ViewModel Model View ViewModel Whatever C# you Model View like! Model View notify changes some messaging Platform Specific Shared
  • 18. @slodge What we want to build… Home Page: Result Page:
  • 23. @slodge Navigation • The HomeViewModel calls: • Which means the TwitterViewModel gets created with:
  • 33. @slodge Inside WP7 App… • No C#, just XAML with {Binding} • Binding syntax includes: {Binding Path, Converter=Converter, ConverterParameter=Parameter, Mode=Mode, FallbackValue=Fallback}
  • 34. @slodge Inside Android App… • No C#, just xml with MvxBind attributes • MvxBind syntax is JSON based on XAML structure.
  • 35. @slodge Binding – Xaml versus Mvx WP7: Text=‚{Binding SearchText,Mode=TwoWay}‛ Android: local:MvxBind=‚{‘Text’: {‘Path’:’SearchText’,’Mode’:’TwoWay’}}‛
  • 36. @slodge Binding – Xaml versus Mvx WP7: Text=‚{Binding Timestamp,Converter={StaticResource TimeAgo}}‛ Android: local:MvxBind=‚{‘Text’: {‘Path’:’Timestamp’,Converter’:’TimeAgo’} }‛
  • 37. @slodge Inside iPhone App • UI is drawn in XML using Xcode • XIB is linked to C# classes using MonoTouch • Binding is declared in C# using JSON
  • 39. @slodge Inside iPad App • The iPad App is actually the iPhone App – “Universal” • But the UI is different – take advantage of the larger screen. • Achieved in code: IMvxTouchViewPresenter
  • 40. @slodge Inside Windows 8 Metro App…
  • 41. @slodge Inside Windows 8 Metro App… It’s like WP7…. • No C#, just XAML with {Binding} • ValueConverters are used in Bindings • Lists are filled using ItemsSource • BUT: Navigation is achieved through code – not Xaml Uri’s
  • 42. @slodge Inside Windows 8 Metro App Warnings: • MvvmCross WinRT implementation is “first cut” – e.g. differences in ViewModel lifecycle • Under-the-hood Win8 implementation is native code – there are big differences. – differences in XAML – differences in .Net/C# • Everything is async.
  • 43. @slodge Inside Windows 8 Metro App… • Beyond the warnings – look at the numbers!
  • 45. @slodge TwitterSearch recap… • Shared C# Core – ViewModels – Models – Services – Converters – Tests • UIs are “mostly XML/JSON”
  • 48. @slodge Panoramas, Pivots and Tabs • Tabbed navigation is another common metaphor across phones and across ipads too. • Generally speaking think of each “tab” as a sub- ViewModel.
  • 49. @slodge Jump Lists • Use grouped list on each viewmodel… • Each platform then works out its own format
  • 50. @slodge Dependency Injection • Useful for testing • Essential for injecting platform specific services – e.g: – Camera capture – GPS services – NFC • MvvmCross wraps OpenNetCF DI – adds some extension methods: – RegisterServiceInstance<TService>(instance) – RegisterServiceType<TService, TServiceType>() – GetService<TService>()
  • 51. @slodge Native Types • Sometimes #define is necessary… • Personally, I try to use interfaces and DI wherever possible.
  • 52. @slodge i18n • Choices: – Each platform has their own localisation format available. – Xamarin are supporting .resx files… – MvvmCross provides a .json file mechanism – Or write your own
  • 53. @slodge Blendability • Limited support available right now. • It’s relatively easy to integrate your own design time ViewModelLocator with design time data…
  • 54. @slodge Problems? • WinRT – issues… • Xcode designer - OMG • iOS development and debugging is most painful • Some compiler differences – JIT • Multiple “core” project files annoying – and breaks refactoring • MvvmCross still changing
  • 56. @slodge That’s all folks… Hopefully we covered: • C# Cross Platform • An Mvvm Introduction • Some Code: TwitterSearch • Some Extras There might be time for: • Q&A