Professional Documents
Culture Documents
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
<?xml version="1.0" encoding="UTF-8"?>
public class HelloWorld : ContentPage <ContentPage xmlns="http://xamarin.com/schemas/2014/fo
{ x:Class="HelloForms.HelloWorld">
public HelloWorld () <StackLayout>
{ <Label Text="Hello World" />
var button = new Button <Button Text="Say Hello"
{ Text = "Say Hello" } ; OnClick="SayHelloClicked" />
button.Clicked += SayHelloClicked; </StackLayout>
</ContentPage>
Content = new StackLayout {
new Label { Text = "Hello World" } , !
button
}; public partial class HelloWorld : ContentPage
} {
! public HelloWorld ()
void SayHelloClicked (object s, EventArgs e) {
{ InitializeComponent ();
// do something }
} void SayHelloClicked (object s, EventArgs e)
} {
// do something
}
}
Your first Xamarin.Forms app
Design a screen
Business Logic
Business Logic
Shared C# User Interface Code
Code sharing/re-use
Shared C# User Interface Code
Controls
Layouts
Pages
How Xamarin.Forms works
Anatomy of a Xamarin.Forms Solution
NuGet Package
How Xamarin.Forms works
Anatomy of a Xamarin.Forms Solution
NuGet Package
App.cs
How Xamarin.Forms works
Anatomy of a Xamarin.Forms Solution
NuGet Package
App.cs
Android app
How Xamarin.Forms works
Anatomy of a Xamarin.Forms Solution
NuGet Package
App.cs
Android app
iOS app
How Xamarin.Forms works
Anatomy of a Xamarin.Forms Solution
NuGet Package
App.cs
Android app
iOS app
!
!
<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>
image: Balsamiq
</ContentPage>
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
MasterDetailPage
iOS does not have a native control Android has a native 'drawer' Windows Phone doesnt have a
for the iPhone, however control which Xamarin.Forms uses. comparable UI metaphor, so
Xamarin.Forms uses Xamarin.Forms provides an
UISplitViewController on iPad. implementation.
Xamarin.Forms brings common UX to everyone
NavigationPage
Android has the navigation stack Windows Phone also has a back-
built in, but Xamarin.Forms adds stack with hardware button, so
iOS has the UINavigationController
the automatic 'back' button for API Xamarin.Forms takes advantage of
which Xamarin.Forms leverages.
consistency. that.
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
!
!
!
Dependency Service
Easily call into platform-specific code
Use DependencyService
!
DependencyService.Get<ITextToSpeech>().Speak("Hello from Xamarin Forms");
!
!
!
Dependency Service
Easily call into platform-specific code
SetBinding in C#
{Binding} in XAML
Messaging
Subscriber Publisher
Center
3. Receive
Custom Renderers
Extend or Create Xamarin.Forms Controls
Attend Jasons
Extending Xamarin.Forms talk
on Thursday
Further Reading
developer.xamarin.com
forums.xamarin.com
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