SlideShare a Scribd company logo
Your First 
Xamarin.Forms 
App 
Craig Dunn 
Developer Evangelist 
@conceptdev
Forget Everything!
Meet Xamarin.Forms 
Build native UIs for iOS, Android and Windows Phone 
from a single, shared C# codebase.
Meet Xamarin.Forms 
Build native UIs for iOS, Android and Windows Phone 
from a single, shared C# codebase.
Meet Xamarin.Forms 
Build native UIs for iOS, Android and Windows Phone 
from a single, shared C# codebase.
Meet Xamarin.Forms 
C# XAML 
public class HelloWorld : ContentPage 
{ 
public HelloWorld () 
{ 
var button = new Button 
{ Text = "Say Hello" } ; 
button.Clicked += SayHelloClicked; 
Content = new StackLayout { 
new Label { Text = "Hello World" } , 
button 
}; 
} 
! 
void SayHelloClicked (object s, EventArgs e) 
{ 
// do something 
} 
} 
<?xml version="1.0" encoding="UTF-8"?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
x:Class="HelloForms.HelloWorld"> 
<StackLayout> 
<Label Text="Hello World" /> 
<Button Text="Say Hello" 
OnClick="SayHelloClicked" /> 
</StackLayout> 
</ContentPage> 
! 
public partial class HelloWorld : ContentPage 
{ 
public HelloWorld () 
{ 
InitializeComponent (); 
} 
void SayHelloClicked (object s, EventArgs e) 
{ 
// do something 
} 
}
Your first Xamarin.Forms app 
■ File > New Project 
■ Design a screen 
■ Add some code 
■ Run on iOS, Android, 
& Windows Phone
Traditional Xamarin Development 
Using the native UI SDKs 
■ Write shared C# code 
■ Database, Web Services 
■ Business Logic 
■ Build native UIs 
■ UIKit & Storyboards on iOS 
■ AXML for Android 
■ XAML for Windows Phone 
■ Share 60-‐80% of the code 
UIKit Layout XAML 
SharedS Ch#a rAepdp A Lpopg iLcogic
UIKit Layout XAML 
Shared C# User Interface Code 
Shared C# App Logic 
Shared App Logic 
Using Xamarin.Forms 
To build the User Interface 
■ Use the same strategies for sharing 
■ Database, Web Services 
■ Business Logic 
■ Build the UI with a single shared 
codebase 
! 
■ Share 99% of the code
Using Xamarin.Forms 
Benefits 
■ Native look and feel 
■ Code sharing/re-‐use 
■ Access to native SDKs using Custom 
Renderers and DependencyService 
■ Camera, accelerometer, GPS, 
■ NFC & more on Android 
■ PassKit & more on iOS 
■ Tiles & more on Windows Phone 
Shared C# User Interface Code 
Shared App Logic 
Shared C# App Logic
How Xamarin.Forms works 
■ Anatomy of a Xamarin.Forms solution 
■ Controls 
■ Layouts 
■ Pages
How Xamarin.Forms works 
Anatomy of a Xamarin.Forms Solution 
■ PCL or Shared Project
How Xamarin.Forms works 
Anatomy of a Xamarin.Forms Solution 
■ PCL or Shared Project 
■ NuGet Package
How Xamarin.Forms works 
Anatomy of a Xamarin.Forms Solution 
■ PCL or Shared Project 
■ NuGet Package 
■ App.cs
How Xamarin.Forms works 
Anatomy of a Xamarin.Forms Solution 
■ PCL or Shared Project 
■ NuGet Package 
■ App.cs 
■ Android app
How Xamarin.Forms works 
Anatomy of a Xamarin.Forms Solution 
■ PCL or Shared Project 
■ NuGet Package 
■ App.cs 
■ Android app 
■ iOS app
How Xamarin.Forms works 
Anatomy of a Xamarin.Forms Solution 
■ PCL or Shared Project 
■ NuGet Package 
■ App.cs 
■ Android app 
■ iOS app 
■ Windows Phone app
How Xamarin.Forms works 
Controls 
var hello = new Label { 
Text = "Hello World" 
}; 
var ok = new Button { Text = "OK" }; 
ok.Clicked += async (sender, e) => { 
await DisplayAlert("OK", 
"You said OK", 
"Done"); 
}; 
! 
! 
<Label Text="Hello World" /> 
<Button Text="OK" 
OnClick="OkClicked" /> 
image: Balsamiq
How Xamarin.Forms works 
Layouts 
var layout = new StackLayout { 
Orientation = StackOrientation.Vertical, 
Children = { 
hello, ok 
} 
}; 
<StackLayout 
Orientation="Vertical"> 
<Label x:Name="hello" 
Text="Hello World" /> 
<Button x:Name="ok" 
Text="OK" 
OnClick="OkClicked"/> 
</StackLayout> 
image: Balsamiq
How Xamarin.Forms works 
Pages 
public class HelloWorld : ContentPage 
{ 
public HelloWorld () 
{ 
var button = new Button { Text = "OK" } ; 
button.Clicked += SayHelloClicked; 
Content = new StackLayout { 
new Label { Text = "Hello World" } , 
button 
}; 
} 
void SayHelloClicked (object s, EventArgs e) 
{ 
// display an alert 
} 
} 
! 
<?xml version="1.0" encoding="UTF-8"?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2009 
x:Class="HelloForms.HelloWorld"> 
<StackLayout Orientation="Vertical"> 
<Label x:Name="hello" Text="Hello World" /> 
<Button x:Name="ok" Text="OK" 
OnClick="OkClicked" /> 
</StackLayout> 
</ContentPage> 
image: Balsamiq
Platform Renderers 
Taking Xamarin.Forms UI to the people (﴾devices)﴿ 
? 
? 
?
Platform Renderers 
Taking Xamarin.Forms UI to the people
Xamarin.Forms brings common UX to everyone 
iOS does not have a native control 
for the iPhone, however 
Xamarin.Forms uses 
UISplitViewController on iPad. 
Android has a native 'drawer' 
control which Xamarin.Forms uses. 
Windows Phone doesn’t have a 
comparable UI metaphor, so 
Xamarin.Forms provides an 
implementation. 
MasterDetailPage
Xamarin.Forms brings common UX to everyone 
iOS has the UINavigationController 
which Xamarin.Forms leverages. 
Android has the navigation stack 
built in, but Xamarin.Forms adds 
the automatic 'back' button for API 
consistency. 
Windows Phone also has a back-‐ 
stack with hardware button, so 
Xamarin.Forms takes advantage of 
that. 
NavigationPage
140 new Controls! 
Welcome to our new Xamarin.Forms partners 
http://blog.xamarin.com/enterprise-‐component-‐ 
vendors-‐join-‐xamarin.forms-‐ecosystem/
Your second Xamarin.Forms app 
■ File > New Project 
■ Design some screens 
■ Add some code 
■ Run on iOS, Android, 
& Windows Phone
Dependency Service 
Easily call into platform-‐specific code 
■ In the common code 
■ Code to an Interface 
public interface ITextToSpeech 
{ 
void Speak (string text); 
} 
! 
! 
DependencyService.Get<ITextToSpeech>().Speak("Hello from Xamarin Forms"); 
! 
! 
!
Dependency Service 
Easily call into platform-‐specific code 
■ In the common code 
■ Code to an Interface 
■ Use DependencyService 
public interface ITextToSpeech 
{ 
void Speak (string text); 
} 
! 
! 
DependencyService.Get<ITextToSpeech>().Speak("Hello from Xamarin Forms"); 
! 
! 
!
Dependency Service 
Easily call into platform-‐specific code 
■ In the common code 
■ Code to an Interface 
■ Use DependencyService 
■ For each platform 
■ implement the Interface 
[assembly: Xamarin.Forms.Dependency (typeof (Speech))] 
public class Speech : ITextToSpeech 
{ 
public Speech () { } 
public void Speak (string text) 
{ 
var speechSynthesizer = new AVSpeechSynthesizer (); 
var speechUtterance = new AVSpeechUtterance (text) { 
Rate = AVSpeechUtterance.MaximumSpeechRate/4, 
Voice = AVSpeechSynthesisVoice.FromLanguage ("en-US"), 
Volume = 0.5f, 
PitchMultiplier = 1.0f 
} ; 
speechSynthesizer.SpeakUtterance (speechUtterance); 
} 
}
Dependency Service 
Easily call into platform-‐specific code 
■ In the common code 
■ Code to an Interface 
■ Use DependencyService 
■ For each platform 
■ implement the Interface 
■ use Dependency 
attribute on the 
assembly 
[assembly: Xamarin.Forms.Dependency (typeof (Speech))] 
public class Speech : ITextToSpeech 
{ 
public Speech () { } 
public void Speak (string text) 
{ 
var speechSynthesizer = new AVSpeechSynthesizer (); 
var speechUtterance = new AVSpeechUtterance (text) { 
Rate = AVSpeechUtterance.MaximumSpeechRate/4, 
Voice = AVSpeechSynthesisVoice.FromLanguage ("en-US"), 
Volume = 0.5f, 
PitchMultiplier = 1.0f 
} ; 
speechSynthesizer.SpeakUtterance (speechUtterance); 
} 
}
Data Binding 
Sync views and models 
■ Enables MVVM-‐style development 
■ SetBinding in C# 
■ {Binding} in XAML 
■ also supports the Command pattern
Messaging Center 
Loosely-‐coupled publish and subscribe 
Subscriber Messaging Publisher 
Center 
1. Register 
3. Receive 
2. Send Message
Custom Renderers 
Extend or Create Xamarin.Forms Controls 
■ Subclass the built-‐in Platform Renderers 
! 
■ Build your own Xamarin.Forms 
control and renderers 
(﴾eg. OxyPlot)﴿ 
! 
■ Attend Jason’s 
Extending Xamarin.Forms talk 
on Thursday
Further Reading… 
■ developer.xamarin.com 
■ forums.xamarin.com 
■ Creating Mobile Apps with 
Xamarin.Forms -‐ Charles Petzold 
PREVIEW EDITION available for 
all Evolve 2014 attendees
What’s next? 
Today 
• Building cross platform applications -‐ Laurent Bugnion 
Tomorrow 
• XAML for Xamarin.Forms -‐ Charles Petzold 
• Extending Xamarin.Forms -‐ Jason Smith 
Friday 
• Xamarin.Forms is Cooler Than You Think -‐ Charles Petzold 
! 
Mini-‐hacks 
• Visit the Darwin Lounge
Your First 
Xamarin.Forms 
App 
Craig Dunn 
@conceptdev 
craig@xamarin.com

More Related Content

What's hot (20)

PDF
ANUG - intro to Xamarin and Xamarin.Forms
James Montemagno
 
PDF
Introduction to Xamarin 3 Seattle Mobile .NET Developers Group
James Montemagno
 
PPTX
Xamarin Forms
Rui Marinho
 
PDF
What's new in Xamarin.Forms?
James Montemagno
 
PPTX
Xamarin Forms
Pranav Ainavolu
 
PDF
Deep Dive in Xamarin.Forms
James Montemagno
 
PDF
Dallas Android - Android & iOS Development in C# with Xamarin
James Montemagno
 
PDF
Introduction to Xamarin Philly Code Camp 2014
James Montemagno
 
PPTX
Xamarin.Forms: a cross-platform mobile UI toolkit - ConFoo 2016
Guy Barrette
 
PDF
Introduction to Mobile Development with Xamarin -DotNet Westide
James Montemagno
 
PPTX
Xamarin overview droidcon.tn
Houssem Dellai
 
PPTX
Xamarin for iOS developers
Craig Dunn
 
PDF
Lessons Learned: 4 Months of Xamarin.Forms
Eric Polerecky
 
PPTX
Connected & Disconnected Apps with Xamarin
Rui Marinho
 
PPTX
Designing cross-platform User Interface with native performance using Xamarin...
Pranav Ainavolu
 
PPTX
Xamarin Overview by Houssem Dellai
Houssem Dellai
 
PDF
Xamarin DevDays Portland - iOS 9
Craig Dunn
 
PPTX
Introduction to Xamarin.Forms 2.x
Craig Dunn
 
PDF
MVP Mix 2015 - Introduction to Xamarin Development
James Montemagno
 
PDF
Extending, optimizing, and accelerating Xamarin and Xamarin.Forms app develop...
James Montemagno
 
ANUG - intro to Xamarin and Xamarin.Forms
James Montemagno
 
Introduction to Xamarin 3 Seattle Mobile .NET Developers Group
James Montemagno
 
Xamarin Forms
Rui Marinho
 
What's new in Xamarin.Forms?
James Montemagno
 
Xamarin Forms
Pranav Ainavolu
 
Deep Dive in Xamarin.Forms
James Montemagno
 
Dallas Android - Android & iOS Development in C# with Xamarin
James Montemagno
 
Introduction to Xamarin Philly Code Camp 2014
James Montemagno
 
Xamarin.Forms: a cross-platform mobile UI toolkit - ConFoo 2016
Guy Barrette
 
Introduction to Mobile Development with Xamarin -DotNet Westide
James Montemagno
 
Xamarin overview droidcon.tn
Houssem Dellai
 
Xamarin for iOS developers
Craig Dunn
 
Lessons Learned: 4 Months of Xamarin.Forms
Eric Polerecky
 
Connected & Disconnected Apps with Xamarin
Rui Marinho
 
Designing cross-platform User Interface with native performance using Xamarin...
Pranav Ainavolu
 
Xamarin Overview by Houssem Dellai
Houssem Dellai
 
Xamarin DevDays Portland - iOS 9
Craig Dunn
 
Introduction to Xamarin.Forms 2.x
Craig Dunn
 
MVP Mix 2015 - Introduction to Xamarin Development
James Montemagno
 
Extending, optimizing, and accelerating Xamarin and Xamarin.Forms app develop...
James Montemagno
 

Viewers also liked (20)

PDF
Navigation in Xamarin.Forms
Kym Phillpotts
 
PPTX
SydMobNet July 2014: Xamarin 3 & Xamarin Forms
Alec Tucker
 
PPTX
Xamarin Forms
Peter Major
 
PPTX
Modern .NET Apps - Telerik Webinar
Sam Basu
 
PPTX
Xamarin day9 - Advance Xamarin Forms
Subodh Pushpak
 
PPT
C# Exceptions Handling
sharqiyem
 
PPTX
Xamarin Forms
Sam Nasr, MCSA, MVP
 
PPTX
Xamarin 2017 : découverte et tips
Edwige Seminara
 
PPTX
Xamarin forms Xaml + C#
Andrés Londoño
 
PPT
Intro to Xamarin.Forms : A C# way to develop mobile app
Mindfire Solutions
 
PPTX
Native cross-platform mobile apps with C# and Xamarin.Forms
Peter Major
 
PDF
DevDay Salerno - Introduzione a Xamarin
Antonio Liccardi
 
PDF
Introducción a Xamarin Forms con XAML
Sorey García
 
PDF
Developing and Designing Native Mobile Apps in Visual Studio
Xamarin
 
PPTX
Introduction to xamarin
Christos Matskas
 
PPTX
Xamarin Forms
Fabio Cozzolino
 
PPTX
Introduction to Xamarin 2.0
Xamarin
 
PPTX
Introduction to cross platform natitve mobile development with c# and xamarin
James Montemagno
 
PPTX
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin
 
PPTX
Visual studio enterprise 2017 mobile by Russ Fustino
Russ Fustino
 
Navigation in Xamarin.Forms
Kym Phillpotts
 
SydMobNet July 2014: Xamarin 3 & Xamarin Forms
Alec Tucker
 
Xamarin Forms
Peter Major
 
Modern .NET Apps - Telerik Webinar
Sam Basu
 
Xamarin day9 - Advance Xamarin Forms
Subodh Pushpak
 
C# Exceptions Handling
sharqiyem
 
Xamarin Forms
Sam Nasr, MCSA, MVP
 
Xamarin 2017 : découverte et tips
Edwige Seminara
 
Xamarin forms Xaml + C#
Andrés Londoño
 
Intro to Xamarin.Forms : A C# way to develop mobile app
Mindfire Solutions
 
Native cross-platform mobile apps with C# and Xamarin.Forms
Peter Major
 
DevDay Salerno - Introduzione a Xamarin
Antonio Liccardi
 
Introducción a Xamarin Forms con XAML
Sorey García
 
Developing and Designing Native Mobile Apps in Visual Studio
Xamarin
 
Introduction to xamarin
Christos Matskas
 
Xamarin Forms
Fabio Cozzolino
 
Introduction to Xamarin 2.0
Xamarin
 
Introduction to cross platform natitve mobile development with c# and xamarin
James Montemagno
 
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin
 
Visual studio enterprise 2017 mobile by Russ Fustino
Russ Fustino
 
Ad

Similar to Your First Xamarin.Forms App (20)

PDF
APAC Webinar: Say Hello To Xamarin.Forms
Nish Anil
 
PPTX
Introduction to Xamarin - Confoo 2015
Guy Barrette
 
PPTX
Introduction to Xamarin
Vinicius Quaiato
 
PDF
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
Nick Landry
 
PDF
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
.NET Conf UY
 
PPTX
20141216 멜팅팟 부산 세션 ii - cross platform 개발
영욱 김
 
PDF
Xamarin Dev Days - Introduction to Xamarin.Forms, Insights, Test Cloud
James Montemagno
 
PDF
Mobile Cross-Platform App Development in C# with Xamarin
Nick Landry
 
PPTX
App innovationcircles xamarin
Mohit Chhabra
 
PPTX
Cross platform mobile app development with Xamarin
Pranav Ainavolu
 
PPTX
Xamarin Open House talk - Sela Group - Ofir Makmal
Ofir Makmal
 
PPTX
[MobConf] Go mobile with C#, Visual Studio & Xamarin
Nish Anil
 
PPTX
Xamarin Development
Alper Ebicoglu
 
PDF
Xamarin Platform
Rui Marinho
 
PPTX
Designing mobile applications with xamarin
Jerel Hass
 
PPTX
Xamarin.Forms a different approach to cross platform natove mobile development
Dan Ardelean
 
PDF
20150812 4시간만에 따라해보는 windows 10 앱 개발
영욱 김
 
PPTX
Xamarin Platform
Liddle Fang
 
PDF
Building Mobile Cross-Platform Apps for iOS, Android & Windows in C# with Xam...
Nick Landry
 
PDF
Cross Platform Mobile Development
Software Infrastructure
 
APAC Webinar: Say Hello To Xamarin.Forms
Nish Anil
 
Introduction to Xamarin - Confoo 2015
Guy Barrette
 
Introduction to Xamarin
Vinicius Quaiato
 
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
Nick Landry
 
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
.NET Conf UY
 
20141216 멜팅팟 부산 세션 ii - cross platform 개발
영욱 김
 
Xamarin Dev Days - Introduction to Xamarin.Forms, Insights, Test Cloud
James Montemagno
 
Mobile Cross-Platform App Development in C# with Xamarin
Nick Landry
 
App innovationcircles xamarin
Mohit Chhabra
 
Cross platform mobile app development with Xamarin
Pranav Ainavolu
 
Xamarin Open House talk - Sela Group - Ofir Makmal
Ofir Makmal
 
[MobConf] Go mobile with C#, Visual Studio & Xamarin
Nish Anil
 
Xamarin Development
Alper Ebicoglu
 
Xamarin Platform
Rui Marinho
 
Designing mobile applications with xamarin
Jerel Hass
 
Xamarin.Forms a different approach to cross platform natove mobile development
Dan Ardelean
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
영욱 김
 
Xamarin Platform
Liddle Fang
 
Building Mobile Cross-Platform Apps for iOS, Android & Windows in C# with Xam...
Nick Landry
 
Cross Platform Mobile Development
Software Infrastructure
 
Ad

More from Craig Dunn (19)

PDF
Visual Studio for Mac (AltConf 2017)
Craig Dunn
 
PDF
EastBay.net Building Mobile Apps with Xamarin and Visual Studio
Craig Dunn
 
PDF
Introduction to iOS 9 (Xamarin Evolve 2016)
Craig Dunn
 
PDF
Wearables with C# and Xamarin
Craig Dunn
 
PPTX
What's New Xamarin.Forms 1.3
Craig Dunn
 
PDF
Introduction to iOS with C# using Xamarin
Craig Dunn
 
PDF
Introduction to Android with C# using Xamarin
Craig Dunn
 
PDF
iOS & Android apps using Parse and Xamarin
Craig Dunn
 
PDF
Azure Mobile Services - more than just cloud data
Craig Dunn
 
PDF
Cloud-enabling iOS & Android apps with C# (using Xamarin)
Craig Dunn
 
PDF
Cloudy with a Chance of Cross Platform (for Bay.NET)
Craig Dunn
 
PDF
Async Await for Mobile Apps
Craig Dunn
 
PDF
Xamarin v.Now
Craig Dunn
 
PDF
C# everywhere
Craig Dunn
 
PDF
Mono for Android... for Google Devs
Craig Dunn
 
KEY
PassKit on iOS6
Craig Dunn
 
ODP
OzAltNet Fast-ANDroid-furious
Craig Dunn
 
PPT
OzAltNet Fast-ANDroid-furious
Craig Dunn
 
PPT
Cross-platform mobile dev with Mono
Craig Dunn
 
Visual Studio for Mac (AltConf 2017)
Craig Dunn
 
EastBay.net Building Mobile Apps with Xamarin and Visual Studio
Craig Dunn
 
Introduction to iOS 9 (Xamarin Evolve 2016)
Craig Dunn
 
Wearables with C# and Xamarin
Craig Dunn
 
What's New Xamarin.Forms 1.3
Craig Dunn
 
Introduction to iOS with C# using Xamarin
Craig Dunn
 
Introduction to Android with C# using Xamarin
Craig Dunn
 
iOS & Android apps using Parse and Xamarin
Craig Dunn
 
Azure Mobile Services - more than just cloud data
Craig Dunn
 
Cloud-enabling iOS & Android apps with C# (using Xamarin)
Craig Dunn
 
Cloudy with a Chance of Cross Platform (for Bay.NET)
Craig Dunn
 
Async Await for Mobile Apps
Craig Dunn
 
Xamarin v.Now
Craig Dunn
 
C# everywhere
Craig Dunn
 
Mono for Android... for Google Devs
Craig Dunn
 
PassKit on iOS6
Craig Dunn
 
OzAltNet Fast-ANDroid-furious
Craig Dunn
 
OzAltNet Fast-ANDroid-furious
Craig Dunn
 
Cross-platform mobile dev with Mono
Craig Dunn
 

Recently uploaded (20)

PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 

Your First Xamarin.Forms App

  • 1. Your First Xamarin.Forms App Craig Dunn Developer Evangelist @conceptdev
  • 3. Meet Xamarin.Forms Build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase.
  • 4. Meet Xamarin.Forms Build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase.
  • 5. Meet Xamarin.Forms Build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase.
  • 6. Meet Xamarin.Forms C# XAML public class HelloWorld : ContentPage { public HelloWorld () { var button = new Button { Text = "Say Hello" } ; button.Clicked += SayHelloClicked; Content = new StackLayout { new Label { Text = "Hello World" } , button }; } ! void SayHelloClicked (object s, EventArgs e) { // do something } } <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" x:Class="HelloForms.HelloWorld"> <StackLayout> <Label Text="Hello World" /> <Button Text="Say Hello" OnClick="SayHelloClicked" /> </StackLayout> </ContentPage> ! public partial class HelloWorld : ContentPage { public HelloWorld () { InitializeComponent (); } void SayHelloClicked (object s, EventArgs e) { // do something } }
  • 7. Your first Xamarin.Forms app ■ File > New Project ■ Design a screen ■ Add some code ■ Run on iOS, Android, & Windows Phone
  • 8. Traditional Xamarin Development Using the native UI SDKs ■ Write shared C# code ■ Database, Web Services ■ Business Logic ■ Build native UIs ■ UIKit & Storyboards on iOS ■ AXML for Android ■ XAML for Windows Phone ■ Share 60-‐80% of the code UIKit Layout XAML SharedS Ch#a rAepdp A Lpopg iLcogic
  • 9. UIKit Layout XAML Shared C# User Interface Code Shared C# App Logic Shared App Logic Using Xamarin.Forms To build the User Interface ■ Use the same strategies for sharing ■ Database, Web Services ■ Business Logic ■ Build the UI with a single shared codebase ! ■ Share 99% of the code
  • 10. Using Xamarin.Forms Benefits ■ Native look and feel ■ Code sharing/re-‐use ■ Access to native SDKs using Custom Renderers and DependencyService ■ Camera, accelerometer, GPS, ■ NFC & more on Android ■ PassKit & more on iOS ■ Tiles & more on Windows Phone Shared C# User Interface Code Shared App Logic Shared C# App Logic
  • 11. How Xamarin.Forms works ■ Anatomy of a Xamarin.Forms solution ■ Controls ■ Layouts ■ Pages
  • 12. How Xamarin.Forms works Anatomy of a Xamarin.Forms Solution ■ PCL or Shared Project
  • 13. How Xamarin.Forms works Anatomy of a Xamarin.Forms Solution ■ PCL or Shared Project ■ NuGet Package
  • 14. How Xamarin.Forms works Anatomy of a Xamarin.Forms Solution ■ PCL or Shared Project ■ NuGet Package ■ App.cs
  • 15. How Xamarin.Forms works Anatomy of a Xamarin.Forms Solution ■ PCL or Shared Project ■ NuGet Package ■ App.cs ■ Android app
  • 16. How Xamarin.Forms works Anatomy of a Xamarin.Forms Solution ■ PCL or Shared Project ■ NuGet Package ■ App.cs ■ Android app ■ iOS app
  • 17. How Xamarin.Forms works Anatomy of a Xamarin.Forms Solution ■ PCL or Shared Project ■ NuGet Package ■ App.cs ■ Android app ■ iOS app ■ Windows Phone app
  • 18. How Xamarin.Forms works Controls var hello = new Label { Text = "Hello World" }; var ok = new Button { Text = "OK" }; ok.Clicked += async (sender, e) => { await DisplayAlert("OK", "You said OK", "Done"); }; ! ! <Label Text="Hello World" /> <Button Text="OK" OnClick="OkClicked" /> image: Balsamiq
  • 19. How Xamarin.Forms works Layouts var layout = new StackLayout { Orientation = StackOrientation.Vertical, Children = { hello, ok } }; <StackLayout Orientation="Vertical"> <Label x:Name="hello" Text="Hello World" /> <Button x:Name="ok" Text="OK" OnClick="OkClicked"/> </StackLayout> image: Balsamiq
  • 20. How Xamarin.Forms works Pages public class HelloWorld : ContentPage { public HelloWorld () { var button = new Button { Text = "OK" } ; button.Clicked += SayHelloClicked; Content = new StackLayout { new Label { Text = "Hello World" } , button }; } void SayHelloClicked (object s, EventArgs e) { // display an alert } } ! <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009 x:Class="HelloForms.HelloWorld"> <StackLayout Orientation="Vertical"> <Label x:Name="hello" Text="Hello World" /> <Button x:Name="ok" Text="OK" OnClick="OkClicked" /> </StackLayout> </ContentPage> image: Balsamiq
  • 21. Platform Renderers Taking Xamarin.Forms UI to the people (﴾devices)﴿ ? ? ?
  • 22. Platform Renderers Taking Xamarin.Forms UI to the people
  • 23. Xamarin.Forms brings common UX to everyone iOS does not have a native control for the iPhone, however Xamarin.Forms uses UISplitViewController on iPad. Android has a native 'drawer' control which Xamarin.Forms uses. Windows Phone doesn’t have a comparable UI metaphor, so Xamarin.Forms provides an implementation. MasterDetailPage
  • 24. Xamarin.Forms brings common UX to everyone iOS has the UINavigationController which Xamarin.Forms leverages. Android has the navigation stack built in, but Xamarin.Forms adds the automatic 'back' button for API consistency. Windows Phone also has a back-‐ stack with hardware button, so Xamarin.Forms takes advantage of that. NavigationPage
  • 25. 140 new Controls! Welcome to our new Xamarin.Forms partners http://blog.xamarin.com/enterprise-‐component-‐ vendors-‐join-‐xamarin.forms-‐ecosystem/
  • 26. Your second Xamarin.Forms app ■ File > New Project ■ Design some screens ■ Add some code ■ Run on iOS, Android, & Windows Phone
  • 27. Dependency Service Easily call into platform-‐specific code ■ In the common code ■ Code to an Interface public interface ITextToSpeech { void Speak (string text); } ! ! DependencyService.Get<ITextToSpeech>().Speak("Hello from Xamarin Forms"); ! ! !
  • 28. Dependency Service Easily call into platform-‐specific code ■ In the common code ■ Code to an Interface ■ Use DependencyService public interface ITextToSpeech { void Speak (string text); } ! ! DependencyService.Get<ITextToSpeech>().Speak("Hello from Xamarin Forms"); ! ! !
  • 29. Dependency Service Easily call into platform-‐specific code ■ In the common code ■ Code to an Interface ■ Use DependencyService ■ For each platform ■ implement the Interface [assembly: Xamarin.Forms.Dependency (typeof (Speech))] public class Speech : ITextToSpeech { public Speech () { } public void Speak (string text) { var speechSynthesizer = new AVSpeechSynthesizer (); var speechUtterance = new AVSpeechUtterance (text) { Rate = AVSpeechUtterance.MaximumSpeechRate/4, Voice = AVSpeechSynthesisVoice.FromLanguage ("en-US"), Volume = 0.5f, PitchMultiplier = 1.0f } ; speechSynthesizer.SpeakUtterance (speechUtterance); } }
  • 30. Dependency Service Easily call into platform-‐specific code ■ In the common code ■ Code to an Interface ■ Use DependencyService ■ For each platform ■ implement the Interface ■ use Dependency attribute on the assembly [assembly: Xamarin.Forms.Dependency (typeof (Speech))] public class Speech : ITextToSpeech { public Speech () { } public void Speak (string text) { var speechSynthesizer = new AVSpeechSynthesizer (); var speechUtterance = new AVSpeechUtterance (text) { Rate = AVSpeechUtterance.MaximumSpeechRate/4, Voice = AVSpeechSynthesisVoice.FromLanguage ("en-US"), Volume = 0.5f, PitchMultiplier = 1.0f } ; speechSynthesizer.SpeakUtterance (speechUtterance); } }
  • 31. Data Binding Sync views and models ■ Enables MVVM-‐style development ■ SetBinding in C# ■ {Binding} in XAML ■ also supports the Command pattern
  • 32. Messaging Center Loosely-‐coupled publish and subscribe Subscriber Messaging Publisher Center 1. Register 3. Receive 2. Send Message
  • 33. Custom Renderers Extend or Create Xamarin.Forms Controls ■ Subclass the built-‐in Platform Renderers ! ■ Build your own Xamarin.Forms control and renderers (﴾eg. OxyPlot)﴿ ! ■ Attend Jason’s Extending Xamarin.Forms talk on Thursday
  • 34. Further Reading… ■ developer.xamarin.com ■ forums.xamarin.com ■ Creating Mobile Apps with Xamarin.Forms -‐ Charles Petzold PREVIEW EDITION available for all Evolve 2014 attendees
  • 35. What’s next? Today • Building cross platform applications -‐ Laurent Bugnion Tomorrow • XAML for Xamarin.Forms -‐ Charles Petzold • Extending Xamarin.Forms -‐ Jason Smith Friday • Xamarin.Forms is Cooler Than You Think -‐ Charles Petzold ! Mini-‐hacks • Visit the Darwin Lounge
  • 36. Your First Xamarin.Forms App Craig Dunn @conceptdev [email protected]