CROSS PLATFORM 
MOBILE DEV WITH C# 
AND XAMARIN 3 
Ed Snider 
Aug 19 2014 
Rappahannock Area 
Developers .NET Users 
Group (RADNUG)
CONTENT 
Introduction 
The Problem with Native Mobile App Dev 
The Benefits of Multi-Platform Mobile Dev with C# 
How? 
- MVVM 
- Share Code 
- Xamarin 
Share UI Code w/ Xamarin.Forms 
DEMO
INTRODUCTION 
Ed Snider - @edsnider | www.edsnider.net 
Developer at InfernoRed Technology 
Co-Organizer of NoVA Mobile C# Developers’ Group 
www.infernored.com 
@infernoredtech 
www.novamobiledev.org 
@novamobiledev
THE PROBLEM WITH 
TRADITIONAL NATIVE MOBILE 
APP DEV… 
Native mobile apps are great but here’s the problem: 
Several Platforms: Windows, iOS, Android 
Several Languages: C#, Objective-C, Java 
Maintenance nightmares 
Customers and end-users suffer
THE BENEFITS OF MULTI-PLATFORM 
NATIVE MOBILE APP DEV 
WITH C# Develop for all platforms with a single language – C# - using Xamarin 
Harness the power of the .NET framework 
Single solution with shared code 
Unified and consistent maintenance/testing 
Feature parity across platforms = happy end users
HOW?
LEVERAGE THE MVVM 
PATTERN 
View (UI) 
Data Binding 
Commands 
ViewModel 
Model 
Platform Specific 
Service Implementations 
Service 
Interfaces 
Connectivity 
Location 
Camera 
Etc…
SHARE CODE! 
Windows iOS Android 
View / UI 
View / UI 
Platform Specifics 
Platform Specifics 
Portable Class Library (PCL) 
ViewModels 
Models 
Core App Library 
View / UI 
Platform Specifics 
Services, Business Logic, Service Access, Data Access, etc.
XAMARIN… 
Xamarin is built on Mono 
Allows native app compilation on Android and iOS using C# 
100% API Coverage – All iOS and Android APIs 
are exposed as C# class libraries 
Up-to-date with API releases 
from Apple and Google
WINDOWS APIS 
100% Coverage
IOS APIS 
100% Coverage
ANDROID APIS 
100% Coverage
HOW XAMARIN WORKS 
C# + .NET Runtime 
Native UI 
Native Performance
XAMARIN DEVELOPMENT 
TOOLS 
Xamarin for Visual Studio Xamarin Studio for Windows and Mac
SHARE UI CODE, TOO!
XAMARIN.FORMS 
Set of APIs that abstract platform specific UI elements and behaviors 
Write UI code once and it is rendered natively across iOS, Android and Window Phone 
Use C# and/or XAML 
Ships as NuGet packages 
Views can now live in the PCL 
Mix and match with platform APIs 
Shared UI Code
XAMARIN.FORMS CONTROLS 
Pages (e.g., Master-detail, Tabs, Carousel) 
Layouts (e.g., Stack, Grid) 
Views (e.g., Button, Label) 
Cells (e.g., templates for table/list items)
XAMARIN.FORMS PAGES 
Xamarin.Forms.Page 
Represents UI screens 
Page = Activity on Android 
Page = View Controller on iOS 
Page = Page on Windows Phone 
Xamarin.Forms Pages Documentation
XAMARIN.FORMS LAYOUTS 
Represents UI containers 
Logically structures UI elements 
Xamarin.Forms Layouts Documentation
XAMARIN.FORMS VIEWS 
Represents UI controls 
Implemented natively and 
platform specific 
Entry = EditText on Android 
Entry = UITextField on iOS 
Entry = Textbox on Windows Phone 
Xamarin.Forms Views 
Documentation
SOME OTHER COOL THINGS 
ABOUT XAMARIN… 
Component Store: http://components.xamarin.com/ 
.NET Mobility Scanner: http://scan.xamarin.com/ 
F#: http://developer.xamarin.com/guides/cross-platform/ 
fsharp/fsharp_support_overview/ 
Xamarin Test Cloud: http://xamarin.com/test-cloud
RESOURCES 
Xamarin.Forms Intro 
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/ 
introduction-to-xamarin-forms/ 
Code from my demo 
https://github.com/edsnider/CoffeeFinder-XamarinFormsDemo 
Image credit: https://octodex.github.com/

Cross Platform Mobile Dev with C# and Xamarin 3 (RADNUG 8/19/14)

  • 1.
    CROSS PLATFORM MOBILEDEV WITH C# AND XAMARIN 3 Ed Snider Aug 19 2014 Rappahannock Area Developers .NET Users Group (RADNUG)
  • 2.
    CONTENT Introduction TheProblem with Native Mobile App Dev The Benefits of Multi-Platform Mobile Dev with C# How? - MVVM - Share Code - Xamarin Share UI Code w/ Xamarin.Forms DEMO
  • 3.
    INTRODUCTION Ed Snider- @edsnider | www.edsnider.net Developer at InfernoRed Technology Co-Organizer of NoVA Mobile C# Developers’ Group www.infernored.com @infernoredtech www.novamobiledev.org @novamobiledev
  • 4.
    THE PROBLEM WITH TRADITIONAL NATIVE MOBILE APP DEV… Native mobile apps are great but here’s the problem: Several Platforms: Windows, iOS, Android Several Languages: C#, Objective-C, Java Maintenance nightmares Customers and end-users suffer
  • 5.
    THE BENEFITS OFMULTI-PLATFORM NATIVE MOBILE APP DEV WITH C# Develop for all platforms with a single language – C# - using Xamarin Harness the power of the .NET framework Single solution with shared code Unified and consistent maintenance/testing Feature parity across platforms = happy end users
  • 6.
  • 7.
    LEVERAGE THE MVVM PATTERN View (UI) Data Binding Commands ViewModel Model Platform Specific Service Implementations Service Interfaces Connectivity Location Camera Etc…
  • 8.
    SHARE CODE! WindowsiOS Android View / UI View / UI Platform Specifics Platform Specifics Portable Class Library (PCL) ViewModels Models Core App Library View / UI Platform Specifics Services, Business Logic, Service Access, Data Access, etc.
  • 9.
    XAMARIN… Xamarin isbuilt on Mono Allows native app compilation on Android and iOS using C# 100% API Coverage – All iOS and Android APIs are exposed as C# class libraries Up-to-date with API releases from Apple and Google
  • 10.
  • 11.
    IOS APIS 100%Coverage
  • 12.
  • 13.
    HOW XAMARIN WORKS C# + .NET Runtime Native UI Native Performance
  • 14.
    XAMARIN DEVELOPMENT TOOLS Xamarin for Visual Studio Xamarin Studio for Windows and Mac
  • 15.
  • 16.
    XAMARIN.FORMS Set ofAPIs that abstract platform specific UI elements and behaviors Write UI code once and it is rendered natively across iOS, Android and Window Phone Use C# and/or XAML Ships as NuGet packages Views can now live in the PCL Mix and match with platform APIs Shared UI Code
  • 17.
    XAMARIN.FORMS CONTROLS Pages(e.g., Master-detail, Tabs, Carousel) Layouts (e.g., Stack, Grid) Views (e.g., Button, Label) Cells (e.g., templates for table/list items)
  • 18.
    XAMARIN.FORMS PAGES Xamarin.Forms.Page Represents UI screens Page = Activity on Android Page = View Controller on iOS Page = Page on Windows Phone Xamarin.Forms Pages Documentation
  • 19.
    XAMARIN.FORMS LAYOUTS RepresentsUI containers Logically structures UI elements Xamarin.Forms Layouts Documentation
  • 20.
    XAMARIN.FORMS VIEWS RepresentsUI controls Implemented natively and platform specific Entry = EditText on Android Entry = UITextField on iOS Entry = Textbox on Windows Phone Xamarin.Forms Views Documentation
  • 21.
    SOME OTHER COOLTHINGS ABOUT XAMARIN… Component Store: http://components.xamarin.com/ .NET Mobility Scanner: http://scan.xamarin.com/ F#: http://developer.xamarin.com/guides/cross-platform/ fsharp/fsharp_support_overview/ Xamarin Test Cloud: http://xamarin.com/test-cloud
  • 22.
    RESOURCES Xamarin.Forms Intro http://developer.xamarin.com/guides/cross-platform/xamarin-forms/ introduction-to-xamarin-forms/ Code from my demo https://github.com/edsnider/CoffeeFinder-XamarinFormsDemo Image credit: https://octodex.github.com/

Editor's Notes

  • #11 If you are a windows developer you will be used to these name spaces. These are the core .NET base libraries that we know and love. If you mix in windows phone and windows store development you get new namespaces Windows. And Microsoft. With platform specific APIs
  • #12 Xamarin gives you the best of both worlds with full support for the .NET Framework (your System. Libraries) Then they create C# bindings for every API in iOS and Android As you can see here there are a few, CoreGraphics, CoreMotion, etc, These are your platform specific bits to take advantage of everything in iOS
  • #13 Then they do the same thing for Android so here you get the Android specifics Renderscript, NFC to do cool phone tapping of data transfer And text to speech apis to make your app shine
  • #14 On iOS Xamarin Compiles the C# down to IL (intermediate language) Then Xamarin create LLVM bit code Then the LLVM bit code runs through the same LLVM Compiler and Optimizer that apple users for objective-c code Creating the final native arm binary. On Android they use an advanced compiler and linking to IL and then JIT to create native instructions at runtime for optimal performance which often can be faster than the dalvik runtime.