SlideShare a Scribd company logo
Making your native apps
even more cross-platform
using MVVM
Jim Bennett
Mobile Developer at EROAD
@JimBobBennett
https://JimBobBennett.io
https://github.com/jimbobbennett
Author of Xamarin in Action
Learn how to build production-quality Xamarin apps using MVVM
to increase the amount of cross-platform code
Now available as part of the Manning Early Access Program
http://xam.jbb.io
Why do we use Xamarin?
Common languages and
framework
Code can be shared across
platforms
Xamarin Cross-Platform apps
• Xamarin apps are native apps
• Code written using the core libraries
can be shared across all platforms
using PCLs
• Only the platform specific stuff is not
cross platform
MVVM increases the amount of
testable shared code in your apps
Example - TipCalc
Business logic - in shared
code in a PCL
public class TipCalculator

{

public decimal Calculate(decimal amount) !=> amount*0.15m;

}

UI - in platform-specific code
in iOS/Android app projects
UI is wired up to business
logic in platform-specific code
!// Android

Calculate.Click += (s, e) !=>

{

var amount = Convert.ToDecimal(BillAmount.Text);

TipAmount.Text = _tipCalculator.Calculate(amount).ToString("C2");

};



Calculate.Enabled = false;

BillAmount.TextChanged += (s, e) !=> Calculate.Enabled = !string.IsNullOrEmpty(BillAmount.Text);

!// iOS

Calculate.TouchUpInside += (s, e) !=>

{

var amount = Convert.ToDecimal(BillAmount.Text);

TipAmount.Text = _tipCalculator.Calculate(amount).ToString("C2");

};



Calculate.Enabled = false;

BillAmount.AddTarget((s, e) !=> Calculate.Enabled = !string.IsNullOrEmpty(BillAmount.Text), 

UIControlEvent.EditingChanged);

Only the business logic can
be unit tested
Only the business logic is
cross-platform
The more cross-platform
code the better
MVVM FTW!
What is MVVM?
• Design pattern used for building UI
based apps - originally invented by
Microsoft for WPF
• Model is business logic
• View is pure UI, no logic
• View Model is UI logic
• Binding wires up view to view model
Model layer is business logic
• Written using cross-platform code
• Can be unit tested
• TipCalculator would be part of the model layer
View layer is pure UI
• Written using platform-specific code
• Cannot be unit tested
• iOS ViewController/Storyboard and Android
Activity/layout would be part of the view layer
ViewModel layer and bindings
are where all the magic is
Each view is backed by a
view model
TipCalcView
public class TipCalcViewModel :
INotifyPropertyChanged

{

!!...

}
TipCalcViewModel
State comes from properties
• When these properties change an event is raised
• The binding layer listens to this event and updates
the UI
• Can be used for data, or properties that define the
UI
• Value converters can be used to change the type
Behaviour comes from
commands
• Commands are objects that wrap actions
• Commands can control if they can be executed
• The binding layer listens to UI events and executes
commands
• If the commands cannot be execute the binding
layer can update the UI to reflect this
View models can also handle
navigation
• Each view has one view model
• Navigation is from view model to view model
• The MVVM framework finds the right view for a
view model and shows it
Xamarin Cross-Platform apps
with MVVM
• Business logic and UI logic can be in
platform specific code
• Commands and property notifications
provide a cross-platform way to
interact with the UI
• Some application logic is shared
• Less platform specific code
Demo time!
MVVM Frameworks
What about Xamarin
Forms?
Xamarin Forms was
built for MVVM!
MVVM increases the amount of
testable shared code in your apps
Jim Bennett
Mobile Application Developer at EROAD
@JimBobBennett
https://JimBobBennett.io
Sample code at:
https://github.com/jimbobbennett/CrossPlatformSummit
Author of Xamarin in Action
Learn how to build production-quality Xamarin apps using MVVM
to increase the amount of cross-platform code
Now available as part of the Manning Early Access Program
http://xam.jbb.io
Ad

More Related Content

What's hot (20)

Say hello to Xamarin 3
Say hello to Xamarin 3Say hello to Xamarin 3
Say hello to Xamarin 3
Xamarin
 
Native App Development for iOS, Android, and Windows with Visual Studio
Native App Development for iOS, Android, and Windows with Visual StudioNative App Development for iOS, Android, and Windows with Visual Studio
Native App Development for iOS, Android, and Windows with Visual Studio
Xamarin
 
Cross-platform Mobile Development
Cross-platform Mobile DevelopmentCross-platform Mobile Development
Cross-platform Mobile Development
Xamarin
 
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
Gill Cleeren
 
Universal Windows Platform
Universal Windows PlatformUniversal Windows Platform
Universal Windows Platform
Software Infrastructure
 
Cross Platform Mobile Development
Cross Platform Mobile DevelopmentCross Platform Mobile Development
Cross Platform Mobile Development
Software Infrastructure
 
Building hybrid apps with Xamarin, Ryan Paul
Building hybrid apps with Xamarin, Ryan PaulBuilding hybrid apps with Xamarin, Ryan Paul
Building hybrid apps with Xamarin, Ryan Paul
Xamarin
 
Cross Platform Development with Xamarin
Cross Platform Development with XamarinCross Platform Development with Xamarin
Cross Platform Development with Xamarin
Xpand IT
 
Xamarin Platform
Xamarin PlatformXamarin Platform
Xamarin Platform
Rui Marinho
 
An introduction to Xamarin
An introduction to XamarinAn introduction to Xamarin
An introduction to Xamarin
Cynoteck Technology Solutions Private Limited
 
Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4
Xamarin
 
Intro to Building Mobile Apps with Xamarin
Intro to Building Mobile Apps with XamarinIntro to Building Mobile Apps with Xamarin
Intro to Building Mobile Apps with Xamarin
Heather Downing
 
Developing and Designing Native Mobile Apps in Visual Studio
Developing and Designing Native Mobile Apps in Visual StudioDeveloping and Designing Native Mobile Apps in Visual Studio
Developing and Designing Native Mobile Apps in Visual Studio
Xamarin
 
Xamarin.Forms
Xamarin.FormsXamarin.Forms
Xamarin.Forms
marcofolio
 
Cross platform development with c# and xamarin
Cross platform development with c# and xamarinCross platform development with c# and xamarin
Cross platform development with c# and xamarin
Luca Zulian
 
Cross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and XamarinCross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and Xamarin
KMS Technology
 
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful ServicesHitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
Heather Downing
 
Hybrid Mobile Development
Hybrid Mobile DevelopmentHybrid Mobile Development
Hybrid Mobile Development
Shai Raiten
 
Smaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giantSmaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giant
Heather Downing
 
Building Your First Android App with Xamarin
Building Your First Android App with XamarinBuilding Your First Android App with Xamarin
Building Your First Android App with Xamarin
Xamarin
 
Say hello to Xamarin 3
Say hello to Xamarin 3Say hello to Xamarin 3
Say hello to Xamarin 3
Xamarin
 
Native App Development for iOS, Android, and Windows with Visual Studio
Native App Development for iOS, Android, and Windows with Visual StudioNative App Development for iOS, Android, and Windows with Visual Studio
Native App Development for iOS, Android, and Windows with Visual Studio
Xamarin
 
Cross-platform Mobile Development
Cross-platform Mobile DevelopmentCross-platform Mobile Development
Cross-platform Mobile Development
Xamarin
 
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
Gill Cleeren
 
Building hybrid apps with Xamarin, Ryan Paul
Building hybrid apps with Xamarin, Ryan PaulBuilding hybrid apps with Xamarin, Ryan Paul
Building hybrid apps with Xamarin, Ryan Paul
Xamarin
 
Cross Platform Development with Xamarin
Cross Platform Development with XamarinCross Platform Development with Xamarin
Cross Platform Development with Xamarin
Xpand IT
 
Xamarin Platform
Xamarin PlatformXamarin Platform
Xamarin Platform
Rui Marinho
 
Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4
Xamarin
 
Intro to Building Mobile Apps with Xamarin
Intro to Building Mobile Apps with XamarinIntro to Building Mobile Apps with Xamarin
Intro to Building Mobile Apps with Xamarin
Heather Downing
 
Developing and Designing Native Mobile Apps in Visual Studio
Developing and Designing Native Mobile Apps in Visual StudioDeveloping and Designing Native Mobile Apps in Visual Studio
Developing and Designing Native Mobile Apps in Visual Studio
Xamarin
 
Cross platform development with c# and xamarin
Cross platform development with c# and xamarinCross platform development with c# and xamarin
Cross platform development with c# and xamarin
Luca Zulian
 
Cross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and XamarinCross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and Xamarin
KMS Technology
 
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful ServicesHitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
Heather Downing
 
Hybrid Mobile Development
Hybrid Mobile DevelopmentHybrid Mobile Development
Hybrid Mobile Development
Shai Raiten
 
Smaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giantSmaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giant
Heather Downing
 
Building Your First Android App with Xamarin
Building Your First Android App with XamarinBuilding Your First Android App with Xamarin
Building Your First Android App with Xamarin
Xamarin
 

Viewers also liked (12)

Building Quality Cross-Platform Apps with Xamarin
Building Quality Cross-Platform Apps with XamarinBuilding Quality Cross-Platform Apps with Xamarin
Building Quality Cross-Platform Apps with Xamarin
Xpand IT
 
CONCEPTO DE INFORMATICA
CONCEPTO DE INFORMATICACONCEPTO DE INFORMATICA
CONCEPTO DE INFORMATICA
caritotrujillor
 
Important Things Of Boot Camp
Important Things Of Boot CampImportant Things Of Boot Camp
Important Things Of Boot Camp
Elite Gamespeed
 
Mobile first ux
Mobile first uxMobile first ux
Mobile first ux
Baidurjya Sinha ( Tatan )
 
03 cross platform design
03 cross platform design03 cross platform design
03 cross platform design
memeapps
 
IBM MobileFirst - Hybrid App Development
IBM MobileFirst - Hybrid App DevelopmentIBM MobileFirst - Hybrid App Development
IBM MobileFirst - Hybrid App Development
Wim Tobback
 
Cross platform mobile developement introduction
Cross platform mobile developement   introductionCross platform mobile developement   introduction
Cross platform mobile developement introduction
Marcel de Vries
 
Most Popular Cross Platform Mobile Development Tools
Most Popular Cross Platform Mobile Development ToolsMost Popular Cross Platform Mobile Development Tools
Most Popular Cross Platform Mobile Development Tools
Grey Matter India Technologies PVT LTD
 
Synapse india reviews on mobile application development
Synapse india reviews on mobile application developmentSynapse india reviews on mobile application development
Synapse india reviews on mobile application development
saritasingh19866
 
Cross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinCross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with Xamarin
bryan costanich
 
Cross Platform Mobile Application Development Using Xamarin and C#
Cross Platform Mobile Application Development Using Xamarin and C#Cross Platform Mobile Application Development Using Xamarin and C#
Cross Platform Mobile Application Development Using Xamarin and C#
EastBanc Tachnologies
 
360 Flex Atlanta
360 Flex Atlanta360 Flex Atlanta
360 Flex Atlanta
rtretola
 
Building Quality Cross-Platform Apps with Xamarin
Building Quality Cross-Platform Apps with XamarinBuilding Quality Cross-Platform Apps with Xamarin
Building Quality Cross-Platform Apps with Xamarin
Xpand IT
 
Important Things Of Boot Camp
Important Things Of Boot CampImportant Things Of Boot Camp
Important Things Of Boot Camp
Elite Gamespeed
 
03 cross platform design
03 cross platform design03 cross platform design
03 cross platform design
memeapps
 
IBM MobileFirst - Hybrid App Development
IBM MobileFirst - Hybrid App DevelopmentIBM MobileFirst - Hybrid App Development
IBM MobileFirst - Hybrid App Development
Wim Tobback
 
Cross platform mobile developement introduction
Cross platform mobile developement   introductionCross platform mobile developement   introduction
Cross platform mobile developement introduction
Marcel de Vries
 
Synapse india reviews on mobile application development
Synapse india reviews on mobile application developmentSynapse india reviews on mobile application development
Synapse india reviews on mobile application development
saritasingh19866
 
Cross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinCross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with Xamarin
bryan costanich
 
Cross Platform Mobile Application Development Using Xamarin and C#
Cross Platform Mobile Application Development Using Xamarin and C#Cross Platform Mobile Application Development Using Xamarin and C#
Cross Platform Mobile Application Development Using Xamarin and C#
EastBanc Tachnologies
 
360 Flex Atlanta
360 Flex Atlanta360 Flex Atlanta
360 Flex Atlanta
rtretola
 
Ad

Similar to Cross platform Xamarin Apps With MVVM (20)

Diving Into Xamarin.Forms
Diving Into Xamarin.Forms Diving Into Xamarin.Forms
Diving Into Xamarin.Forms
Catapult New Business
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
SolTech, Inc.
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
Xamarin.Forms Advanced Topics
Xamarin.Forms Advanced TopicsXamarin.Forms Advanced Topics
Xamarin.Forms Advanced Topics
Alejandro Ruiz Varela
 
Automatic code generation for cross platform, multi-device mobile apps. An in...
Automatic code generation for cross platform, multi-device mobile apps. An in...Automatic code generation for cross platform, multi-device mobile apps. An in...
Automatic code generation for cross platform, multi-device mobile apps. An in...
Marco Brambilla
 
Building xamarin.forms apps with prism and mvvm
Building xamarin.forms apps with prism and mvvmBuilding xamarin.forms apps with prism and mvvm
Building xamarin.forms apps with prism and mvvm
Mike Melusky
 
Why is xamarin the preferred app development platform among app developers
Why is xamarin the preferred app development platform among app developersWhy is xamarin the preferred app development platform among app developers
Why is xamarin the preferred app development platform among app developers
Fullestop
 
Lecture 08 Xamarin
Lecture 08 XamarinLecture 08 Xamarin
Lecture 08 Xamarin
Maksym Davydov
 
Xamarin介紹
Xamarin介紹Xamarin介紹
Xamarin介紹
Proaben Sherlock
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
Dia 4.1 mvvm cross
Dia 4.1   mvvm crossDia 4.1   mvvm cross
Dia 4.1 mvvm cross
Hernan Zaldivar
 
Building Cross-Platform JavaScript Apps using Cordova
Building Cross-Platform JavaScript Apps using CordovaBuilding Cross-Platform JavaScript Apps using Cordova
Building Cross-Platform JavaScript Apps using Cordova
Noam Kfir
 
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossC# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
Flavius-Radu Demian
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
Alejandro Ruiz Varela
 
Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...
Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...
Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...
YASH Technologies
 
Xamarin Development
Xamarin DevelopmentXamarin Development
Xamarin Development
Alper Ebicoglu
 
SpringCloudConfig.pptx.pdf
SpringCloudConfig.pptx.pdfSpringCloudConfig.pptx.pdf
SpringCloudConfig.pptx.pdf
Knoldus Inc.
 
Prism library and MVVM
Prism library and MVVMPrism library and MVVM
Prism library and MVVM
Jiri Danihelka
 
Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...
Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...
Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...
Codemotion
 
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossC# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
Flavius-Radu Demian
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
SolTech, Inc.
 
Automatic code generation for cross platform, multi-device mobile apps. An in...
Automatic code generation for cross platform, multi-device mobile apps. An in...Automatic code generation for cross platform, multi-device mobile apps. An in...
Automatic code generation for cross platform, multi-device mobile apps. An in...
Marco Brambilla
 
Building xamarin.forms apps with prism and mvvm
Building xamarin.forms apps with prism and mvvmBuilding xamarin.forms apps with prism and mvvm
Building xamarin.forms apps with prism and mvvm
Mike Melusky
 
Why is xamarin the preferred app development platform among app developers
Why is xamarin the preferred app development platform among app developersWhy is xamarin the preferred app development platform among app developers
Why is xamarin the preferred app development platform among app developers
Fullestop
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
Building Cross-Platform JavaScript Apps using Cordova
Building Cross-Platform JavaScript Apps using CordovaBuilding Cross-Platform JavaScript Apps using Cordova
Building Cross-Platform JavaScript Apps using Cordova
Noam Kfir
 
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossC# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
Flavius-Radu Demian
 
Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...
Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...
Xamarin Technical Assessment Against Native for Cross Platform Mobile Develop...
YASH Technologies
 
SpringCloudConfig.pptx.pdf
SpringCloudConfig.pptx.pdfSpringCloudConfig.pptx.pdf
SpringCloudConfig.pptx.pdf
Knoldus Inc.
 
Prism library and MVVM
Prism library and MVVMPrism library and MVVM
Prism library and MVVM
Jiri Danihelka
 
Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...
Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...
Xamarin in real life: our MVP approach - Daniele Leombruni Antonino Cacace - ...
Codemotion
 
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCrossC# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
Flavius-Radu Demian
 
Ad

More from Jim Bennett (10)

Intro to the Cloud from TeenHacks LI
Intro to the Cloud from TeenHacks LIIntro to the Cloud from TeenHacks LI
Intro to the Cloud from TeenHacks LI
Jim Bennett
 
WooHoo my app is on the store! Now what?
WooHoo my app is on the store! Now what?WooHoo my app is on the store! Now what?
WooHoo my app is on the store! Now what?
Jim Bennett
 
Building Fabulous mobile apps with F#
Building Fabulous mobile apps with F#Building Fabulous mobile apps with F#
Building Fabulous mobile apps with F#
Jim Bennett
 
Adding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms appsAdding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms apps
Jim Bennett
 
Learning to love f#
Learning to love f#Learning to love f#
Learning to love f#
Jim Bennett
 
App center - the gateway drug to mobile devops
App center -  the gateway drug to mobile devopsApp center -  the gateway drug to mobile devops
App center - the gateway drug to mobile devops
Jim Bennett
 
Adding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms appsAdding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms apps
Jim Bennett
 
Clicking on the real world with iBeacon and eddystone
Clicking on the real world with iBeacon and eddystoneClicking on the real world with iBeacon and eddystone
Clicking on the real world with iBeacon and eddystone
Jim Bennett
 
IBeacons and Eddystone
IBeacons and EddystoneIBeacons and Eddystone
IBeacons and Eddystone
Jim Bennett
 
Xamarin iBeacon Mini-hack using Estimote iBeacons
Xamarin iBeacon Mini-hack using Estimote iBeaconsXamarin iBeacon Mini-hack using Estimote iBeacons
Xamarin iBeacon Mini-hack using Estimote iBeacons
Jim Bennett
 
Intro to the Cloud from TeenHacks LI
Intro to the Cloud from TeenHacks LIIntro to the Cloud from TeenHacks LI
Intro to the Cloud from TeenHacks LI
Jim Bennett
 
WooHoo my app is on the store! Now what?
WooHoo my app is on the store! Now what?WooHoo my app is on the store! Now what?
WooHoo my app is on the store! Now what?
Jim Bennett
 
Building Fabulous mobile apps with F#
Building Fabulous mobile apps with F#Building Fabulous mobile apps with F#
Building Fabulous mobile apps with F#
Jim Bennett
 
Adding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms appsAdding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms apps
Jim Bennett
 
Learning to love f#
Learning to love f#Learning to love f#
Learning to love f#
Jim Bennett
 
App center - the gateway drug to mobile devops
App center -  the gateway drug to mobile devopsApp center -  the gateway drug to mobile devops
App center - the gateway drug to mobile devops
Jim Bennett
 
Adding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms appsAdding platform specific magic to cross-platform Xamarin Forms apps
Adding platform specific magic to cross-platform Xamarin Forms apps
Jim Bennett
 
Clicking on the real world with iBeacon and eddystone
Clicking on the real world with iBeacon and eddystoneClicking on the real world with iBeacon and eddystone
Clicking on the real world with iBeacon and eddystone
Jim Bennett
 
IBeacons and Eddystone
IBeacons and EddystoneIBeacons and Eddystone
IBeacons and Eddystone
Jim Bennett
 
Xamarin iBeacon Mini-hack using Estimote iBeacons
Xamarin iBeacon Mini-hack using Estimote iBeaconsXamarin iBeacon Mini-hack using Estimote iBeacons
Xamarin iBeacon Mini-hack using Estimote iBeacons
Jim Bennett
 

Recently uploaded (20)

2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 

Cross platform Xamarin Apps With MVVM

  • 1. Making your native apps even more cross-platform using MVVM
  • 2. Jim Bennett Mobile Developer at EROAD @JimBobBennett https://JimBobBennett.io https://github.com/jimbobbennett
  • 3. Author of Xamarin in Action Learn how to build production-quality Xamarin apps using MVVM to increase the amount of cross-platform code Now available as part of the Manning Early Access Program http://xam.jbb.io
  • 4. Why do we use Xamarin?
  • 6. Code can be shared across platforms
  • 7. Xamarin Cross-Platform apps • Xamarin apps are native apps • Code written using the core libraries can be shared across all platforms using PCLs • Only the platform specific stuff is not cross platform
  • 8. MVVM increases the amount of testable shared code in your apps
  • 10. Business logic - in shared code in a PCL public class TipCalculator
 {
 public decimal Calculate(decimal amount) !=> amount*0.15m;
 }

  • 11. UI - in platform-specific code in iOS/Android app projects
  • 12. UI is wired up to business logic in platform-specific code !// Android
 Calculate.Click += (s, e) !=>
 {
 var amount = Convert.ToDecimal(BillAmount.Text);
 TipAmount.Text = _tipCalculator.Calculate(amount).ToString("C2");
 };
 
 Calculate.Enabled = false;
 BillAmount.TextChanged += (s, e) !=> Calculate.Enabled = !string.IsNullOrEmpty(BillAmount.Text);
 !// iOS
 Calculate.TouchUpInside += (s, e) !=>
 {
 var amount = Convert.ToDecimal(BillAmount.Text);
 TipAmount.Text = _tipCalculator.Calculate(amount).ToString("C2");
 };
 
 Calculate.Enabled = false;
 BillAmount.AddTarget((s, e) !=> Calculate.Enabled = !string.IsNullOrEmpty(BillAmount.Text), 
 UIControlEvent.EditingChanged);

  • 13. Only the business logic can be unit tested
  • 14. Only the business logic is cross-platform
  • 17. What is MVVM? • Design pattern used for building UI based apps - originally invented by Microsoft for WPF • Model is business logic • View is pure UI, no logic • View Model is UI logic • Binding wires up view to view model
  • 18. Model layer is business logic • Written using cross-platform code • Can be unit tested • TipCalculator would be part of the model layer
  • 19. View layer is pure UI • Written using platform-specific code • Cannot be unit tested • iOS ViewController/Storyboard and Android Activity/layout would be part of the view layer
  • 20. ViewModel layer and bindings are where all the magic is
  • 21. Each view is backed by a view model TipCalcView public class TipCalcViewModel : INotifyPropertyChanged
 {
 !!...
 } TipCalcViewModel
  • 22. State comes from properties • When these properties change an event is raised • The binding layer listens to this event and updates the UI • Can be used for data, or properties that define the UI • Value converters can be used to change the type
  • 23. Behaviour comes from commands • Commands are objects that wrap actions • Commands can control if they can be executed • The binding layer listens to UI events and executes commands • If the commands cannot be execute the binding layer can update the UI to reflect this
  • 24. View models can also handle navigation • Each view has one view model • Navigation is from view model to view model • The MVVM framework finds the right view for a view model and shows it
  • 25. Xamarin Cross-Platform apps with MVVM • Business logic and UI logic can be in platform specific code • Commands and property notifications provide a cross-platform way to interact with the UI • Some application logic is shared • Less platform specific code
  • 30. MVVM increases the amount of testable shared code in your apps
  • 31. Jim Bennett Mobile Application Developer at EROAD @JimBobBennett https://JimBobBennett.io Sample code at: https://github.com/jimbobbennett/CrossPlatformSummit
  • 32. Author of Xamarin in Action Learn how to build production-quality Xamarin apps using MVVM to increase the amount of cross-platform code Now available as part of the Manning Early Access Program http://xam.jbb.io