SlideShare a Scribd company logo
Native
cross-platform
mobile apps with
C# and
Xamarin.Forms
Peter Major
Apr 25, 2015
Agenda
- Xamarin
- Xamarin Forms
- Should I use Xamarin Forms?
Building Apps Today
Objective-C / Swift - Xcode
Java - Eclipse / Android Studio
.NET - Visual Studio
Native
Hybrid
Code:
HTML + Javascript
Framework:
Ionic + Angular
Container:
Cordova, PhoneGap
What is Xamarin?
C# shared code
Compiled-to-native code
Native UI
What is Xamarin NOT?
Write once, run anywhere UI
Replacement for learning about each platform
Xamarin - iOS
AOT compiled
to ARM assembly
Mono framework included
Exposes CocoaTouch SDK
Xamarin - Android
Compiled to IL
Runs in MonoVM
Exposes Android SDK
Xamarin - Windows Phone
Compiled to IL
Uses built in phone runtime
No Mono / Xamarin SDK required
- Can I use my favorite SDK?
Yes
- Can I use my favorite Nuget package?
Sometimes
FAQ
- Are apps slower than native?
About the same *
- Are apps bigger than native?
Yes
FAQ
* https://medium.com/@harrycheung/mobile-app-performance-redux-e512be94f976
- Can I use async / await?
Yes
- Can I use “xyz” feature of .NET?
Yes *
FAQ
Architecture
from xamarin.com
Xamarin
from hanselman.com
Xamarin + Forms
from xamarin.com
- WPF? Forms will be familiar.
- Develop by feature, not by platform
Xamarin Forms
Forms?
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage x:Class="EntryTest.Login">
<ContentPage.Content>
<StackLayout WidthRequest="200"
HorizontalOptions="Center"
VerticalOptions="Center">
<Entry Placeholder="Username" />
<Entry Placeholder="Password" />
<Button Text="Login"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
XAML or code
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage x:Class="EntryTest.Login">
<ContentPage.Content>
<StackLayout WidthRequest="200"
HorizontalOptions="Center"
VerticalOptions="Center">
<Entry Placeholder="Username" />
<Entry Placeholder="Password" />
<Button Text="Login"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
var page = new ContentPage
{
Content = new StackLayout
{
WidthRequest = 200,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Children =
{
new Entry { Placeholder = "Username" },
new Entry { Placeholder = "Password" },
new Button { Text = "Login" }
}
}
};
How it works
Forms controls
are converted by renderers
to native controls
Same vs Different
- promote brand
- familiar platform
Familiar platform
Customization - Style
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="TextColor" Value="Black" />
<Setter Property="BorderWidth" Value="1" />
<Setter Property="BorderRadius" Value="3" />
<Setter Property="BackgroundColor" Value="{StaticResource ButtonBackgroundColor}" />
<Setter Property="BorderColor" Value="{StaticResource ButtonBorderColor}" />
<Setter Property="Font" Value="{StaticResource ButtonFont}" />
<Style.Triggers>
<Trigger Property="controls:ButtonExtensions.IsPrimary" Value="True" TargetType="Button">
<Setter Property="BackgroundColor" Value="{StaticResource PrimaryBackgroundColor}" />
<Setter Property="BorderColor" Value="{StaticResource PrimaryBorderColor}" />
</Trigger>
</Style.Triggers>
</Style>
Customization - Renderer
public class StandardEntryRenderer : EntryRenderer
{
protected override void OnElementChanged (ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged (e);
if (e.OldElement == null) {
AddBorderToControl ();
Control.Started += (sender, args) => Control.Layer.BorderColor = YellowBorderColor.CGColor;
Control.Ended += (sender, args) => Control.Layer.BorderColor = GreyBorderColor.CGColor;
}
}
void AddBorderToControl()
{
Control.Layer.CornerRadius = 3;
Control.Layer.BorderWidth = 1;
Control.Layer.BorderColor = GreyBorderColor.CGColor;
}
}
Customization - Renderer
public class PullToRefreshViewRenderer : VisualElementRenderer<PullToRefreshView>
{
UIRefreshControl refreshControl;
protected override void OnElementChanged(ElementChangedEventArgs<PullToRefreshView> e)
{
base.OnElementChanged (e);
var renderer = Subviews [0] as ListViewRenderer;
if (renderer == null)
return;
refreshControl = new UIRefreshControl ();
refreshControl.ValueChanged += OnRefreshingChanged;
renderer.Control.AddSubview(refreshControl);
UpdateIsRefreshing();
}
}
Customization - per-platform
<OnPlatform x:TypeArguments="Font"
Android="sans-serif,None,21"
iOS="HelveticaNeue,None,16"
x:Key="TitleFont"/>
<Style x:Key="TitleLabel" TargetType="Label">
<Setter Property="AbsoluteLayout.LayoutBounds" Value="0,0,AutoSize,AutoSize" />
<Setter Property="AbsoluteLayout.LayoutFlags" Value="PositionProportional" />
<Setter Property="Font" Value="{StaticResource TitleFont}" />
<Setter Property="TextColor" Value="#333" />
</Style>
MVVM
<StackLayout>
<Entry Text="{Binding Username}"/>
<Entry Text="{Binding Password}"/>
<Button Text="Login"
Command="{Binding LoginCommand}"/>
</StackLayout>
public class LoginViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public Command LoginCommand { get; private set; }
string _username;
public string Username
{
get { return _username; }
set {
_username = value;
NotifyPropertyChanged(); }
}
// continued…
}
Attached Properties / Triggers
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="TextColor" Value="Black" />
<Setter Property="BorderWidth" Value="1" />
<Setter Property="BorderRadius" Value="3" />
<Setter Property="BackgroundColor" Value="{StaticResource ButtonBackgroundColor}" />
<Setter Property="BorderColor" Value="{StaticResource ButtonBorderColor}" />
<Setter Property="Font" Value="{StaticResource ButtonFont}" />
<Style.Triggers>
<Trigger Property="controls:ButtonExtensions.IsPrimary" Value="True" TargetType="Button">
<Setter Property="BackgroundColor" Value="{StaticResource PrimaryBackgroundColor}" />
<Setter Property="BorderColor" Value="{StaticResource PrimaryBorderColor}" />
</Trigger>
</Style.Triggers>
</Style>
Behaviors
<Entry Placeholder="Enter a System.Double">
<Entry.Behaviors>
<local:NumericValidationBehavior />
</Entry.Behaviors>
</Entry>
public class NumericValidationBehavior : Behavior<Entry>
{
protected override void OnAttachedTo(Entry entry)
{
entry.TextChanged += OnEntryTextChanged;
base.OnAttachedTo(entry);
}
protected override void OnDetachingFrom(Entry entry)
{
entry.TextChanged -= OnEntryTextChanged;
base.OnDetachingFrom(entry);
}
void OnEntryTextChanged(object sender, TextChangedEventArgs args)
{
double result;
bool isValid = Double.TryParse (args.NewTextValue, out result);
((Entry)sender).TextColor = isValid ? Color.Default : Color.Red;
}
}
- DependencyService
- MessagingCenter
- Navigation
Other features
- Are XF apps slower than native?
Yes
- Are XF apps bigger than native?
Yes
Speed / size redux
- New or Existing product?
- New or Existing team?
- Resources vs user experience
Should I use XF?
- Mockups
- Prototypes
And even if you don’t...
- One UI layout
- Very customizable
- Initial customization investment
- Develop by feature
- Very active development
Good
- Bugs, fix with renderers
- Renderers have “internal” code
- No XAML designer
- Open source?
Bad
- Getting started:
http://developer.xamarin.com/guides/cross-platform/getting_started/
- Licensing:
https://store.xamarin.com/
- Samples:
https://github.com/xamarin/monotouch-samples / https://github.com/xamarin/monodroid-
samples
- Forms documentation:
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/
- Forms samples:
https://github.com/xamarin/xamarin-forms-samples
Resources

More Related Content

Viewers also liked

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
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
Christos Matskas
 
Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...
Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...
Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...
Javier Suárez Ruiz
 
Xamarin.Forms
Xamarin.FormsXamarin.Forms
Xamarin.Forms
marcofolio
 
Conociendo el resto de ecosistema Xamarin
Conociendo el resto de ecosistema XamarinConociendo el resto de ecosistema Xamarin
Conociendo el resto de ecosistema Xamarin
Javier Suárez Ruiz
 
Novedades en Visual Studio Online
Novedades en Visual Studio OnlineNovedades en Visual Studio Online
Novedades en Visual Studio Online
Javier Suárez Ruiz
 
Crear Apps Multiplataforma compartiendo la mayor cantidad con Xamarin
Crear Apps Multiplataforma compartiendo la mayor cantidad con XamarinCrear Apps Multiplataforma compartiendo la mayor cantidad con Xamarin
Crear Apps Multiplataforma compartiendo la mayor cantidad con Xamarin
Javier Suárez Ruiz
 
[XamarinDay] Développez en XAML avec Xamarin Forms
[XamarinDay] Développez en XAML avec Xamarin Forms[XamarinDay] Développez en XAML avec Xamarin Forms
[XamarinDay] Développez en XAML avec Xamarin Forms
Cellenza
 
Introduction to Xamarin 2.0
Introduction to Xamarin 2.0Introduction to Xamarin 2.0
Introduction to Xamarin 2.0
Xamarin
 
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin
 
Introducción a Xamarin
Introducción a XamarinIntroducción a Xamarin
Introducción a Xamarin
Javier Suárez Ruiz
 
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOpsXamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin
 
Introducción al desarrollo de Apps en Windows 10
Introducción al desarrollo de Apps en  Windows 10Introducción al desarrollo de Apps en  Windows 10
Introducción al desarrollo de Apps en Windows 10
Javier Suárez Ruiz
 
Introduction à Xamarin
Introduction à XamarinIntroduction à Xamarin
Introduction à Xamarin
Patrice Cote
 

Viewers also liked (14)

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
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
 
Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...
Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...
Crear Apps móviles multiplataforma con Xamarin compartiendo la mayor cantidad...
 
Xamarin.Forms
Xamarin.FormsXamarin.Forms
Xamarin.Forms
 
Conociendo el resto de ecosistema Xamarin
Conociendo el resto de ecosistema XamarinConociendo el resto de ecosistema Xamarin
Conociendo el resto de ecosistema Xamarin
 
Novedades en Visual Studio Online
Novedades en Visual Studio OnlineNovedades en Visual Studio Online
Novedades en Visual Studio Online
 
Crear Apps Multiplataforma compartiendo la mayor cantidad con Xamarin
Crear Apps Multiplataforma compartiendo la mayor cantidad con XamarinCrear Apps Multiplataforma compartiendo la mayor cantidad con Xamarin
Crear Apps Multiplataforma compartiendo la mayor cantidad con Xamarin
 
[XamarinDay] Développez en XAML avec Xamarin Forms
[XamarinDay] Développez en XAML avec Xamarin Forms[XamarinDay] Développez en XAML avec Xamarin Forms
[XamarinDay] Développez en XAML avec Xamarin Forms
 
Introduction to Xamarin 2.0
Introduction to Xamarin 2.0Introduction to Xamarin 2.0
Introduction to Xamarin 2.0
 
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
 
Introducción a Xamarin
Introducción a XamarinIntroducción a Xamarin
Introducción a Xamarin
 
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOpsXamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
 
Introducción al desarrollo de Apps en Windows 10
Introducción al desarrollo de Apps en  Windows 10Introducción al desarrollo de Apps en  Windows 10
Introducción al desarrollo de Apps en Windows 10
 
Introduction à Xamarin
Introduction à XamarinIntroduction à Xamarin
Introduction à Xamarin
 

Similar to Native cross-platform mobile apps with C# and Xamarin.Forms

Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
Fafadia Tech
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
GhanaGTUG
 
android level 3
android level 3android level 3
android level 3
DevMix
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
Xamarin
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
anistar sung
 
Android classes in mumbai
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbai
Vibrant Technologies & Computers
 
Building a Native Camera Access Library - Part II - Transcript.pdf
Building a Native Camera Access Library - Part II - Transcript.pdfBuilding a Native Camera Access Library - Part II - Transcript.pdf
Building a Native Camera Access Library - Part II - Transcript.pdf
ShaiAlmog1
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
Susan Gold
 
Titanium appcelerator best practices
Titanium appcelerator best practicesTitanium appcelerator best practices
Titanium appcelerator best practices
Alessio Ricco
 
Android tips and tricks
Android tips and tricksAndroid tips and tricks
Android tips and tricks
Nikola Kapraljevic Nixa
 
Net conf BG xamarin lecture
Net conf BG xamarin lectureNet conf BG xamarin lecture
Net conf BG xamarin lecture
Tsvyatko Konov
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code less
Anton Novikau
 
Flutter Forward EXTENDED - Flutter로 앱 개발 입문하기
Flutter Forward EXTENDED -  Flutter로 앱 개발 입문하기Flutter Forward EXTENDED -  Flutter로 앱 개발 입문하기
Flutter Forward EXTENDED - Flutter로 앱 개발 입문하기
SuJang Yang
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code Quality
Thomas Moulard
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
Xamarin
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
Hazem Saleh
 
Cross platform mobile apps using .NET
Cross platform mobile apps using .NETCross platform mobile apps using .NET
Cross platform mobile apps using .NET
Jonas Follesø
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
Chandan Jog
 
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows AzureDeveloping Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Rainer Stropek
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
Massimo Oliviero
 

Similar to Native cross-platform mobile apps with C# and Xamarin.Forms (20)

Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
android level 3
android level 3android level 3
android level 3
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Android classes in mumbai
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbai
 
Building a Native Camera Access Library - Part II - Transcript.pdf
Building a Native Camera Access Library - Part II - Transcript.pdfBuilding a Native Camera Access Library - Part II - Transcript.pdf
Building a Native Camera Access Library - Part II - Transcript.pdf
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
Titanium appcelerator best practices
Titanium appcelerator best practicesTitanium appcelerator best practices
Titanium appcelerator best practices
 
Android tips and tricks
Android tips and tricksAndroid tips and tricks
Android tips and tricks
 
Net conf BG xamarin lecture
Net conf BG xamarin lectureNet conf BG xamarin lecture
Net conf BG xamarin lecture
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code less
 
Flutter Forward EXTENDED - Flutter로 앱 개발 입문하기
Flutter Forward EXTENDED -  Flutter로 앱 개발 입문하기Flutter Forward EXTENDED -  Flutter로 앱 개발 입문하기
Flutter Forward EXTENDED - Flutter로 앱 개발 입문하기
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code Quality
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
 
Cross platform mobile apps using .NET
Cross platform mobile apps using .NETCross platform mobile apps using .NET
Cross platform mobile apps using .NET
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows AzureDeveloping Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 

Recently uploaded

Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 

Recently uploaded (20)

Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 

Native cross-platform mobile apps with C# and Xamarin.Forms

  • 1. Native cross-platform mobile apps with C# and Xamarin.Forms Peter Major Apr 25, 2015
  • 2. Agenda - Xamarin - Xamarin Forms - Should I use Xamarin Forms?
  • 4. Objective-C / Swift - Xcode Java - Eclipse / Android Studio .NET - Visual Studio Native
  • 5. Hybrid Code: HTML + Javascript Framework: Ionic + Angular Container: Cordova, PhoneGap
  • 6. What is Xamarin? C# shared code Compiled-to-native code Native UI
  • 7. What is Xamarin NOT? Write once, run anywhere UI Replacement for learning about each platform
  • 8. Xamarin - iOS AOT compiled to ARM assembly Mono framework included Exposes CocoaTouch SDK
  • 9. Xamarin - Android Compiled to IL Runs in MonoVM Exposes Android SDK
  • 10. Xamarin - Windows Phone Compiled to IL Uses built in phone runtime No Mono / Xamarin SDK required
  • 11. - Can I use my favorite SDK? Yes - Can I use my favorite Nuget package? Sometimes FAQ
  • 12. - Are apps slower than native? About the same * - Are apps bigger than native? Yes FAQ * https://medium.com/@harrycheung/mobile-app-performance-redux-e512be94f976
  • 13. - Can I use async / await? Yes - Can I use “xyz” feature of .NET? Yes * FAQ
  • 16. Xamarin + Forms from xamarin.com
  • 17. - WPF? Forms will be familiar. - Develop by feature, not by platform Xamarin Forms
  • 18. Forms? <?xml version="1.0" encoding="UTF-8"?> <ContentPage x:Class="EntryTest.Login"> <ContentPage.Content> <StackLayout WidthRequest="200" HorizontalOptions="Center" VerticalOptions="Center"> <Entry Placeholder="Username" /> <Entry Placeholder="Password" /> <Button Text="Login"/> </StackLayout> </ContentPage.Content> </ContentPage>
  • 19. XAML or code <?xml version="1.0" encoding="UTF-8"?> <ContentPage x:Class="EntryTest.Login"> <ContentPage.Content> <StackLayout WidthRequest="200" HorizontalOptions="Center" VerticalOptions="Center"> <Entry Placeholder="Username" /> <Entry Placeholder="Password" /> <Button Text="Login"/> </StackLayout> </ContentPage.Content> </ContentPage> var page = new ContentPage { Content = new StackLayout { WidthRequest = 200, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Children = { new Entry { Placeholder = "Username" }, new Entry { Placeholder = "Password" }, new Button { Text = "Login" } } } };
  • 20. How it works Forms controls are converted by renderers to native controls
  • 21. Same vs Different - promote brand - familiar platform
  • 23. Customization - Style <Style x:Key="ButtonStyle" TargetType="Button"> <Setter Property="TextColor" Value="Black" /> <Setter Property="BorderWidth" Value="1" /> <Setter Property="BorderRadius" Value="3" /> <Setter Property="BackgroundColor" Value="{StaticResource ButtonBackgroundColor}" /> <Setter Property="BorderColor" Value="{StaticResource ButtonBorderColor}" /> <Setter Property="Font" Value="{StaticResource ButtonFont}" /> <Style.Triggers> <Trigger Property="controls:ButtonExtensions.IsPrimary" Value="True" TargetType="Button"> <Setter Property="BackgroundColor" Value="{StaticResource PrimaryBackgroundColor}" /> <Setter Property="BorderColor" Value="{StaticResource PrimaryBorderColor}" /> </Trigger> </Style.Triggers> </Style>
  • 24. Customization - Renderer public class StandardEntryRenderer : EntryRenderer { protected override void OnElementChanged (ElementChangedEventArgs<Entry> e) { base.OnElementChanged (e); if (e.OldElement == null) { AddBorderToControl (); Control.Started += (sender, args) => Control.Layer.BorderColor = YellowBorderColor.CGColor; Control.Ended += (sender, args) => Control.Layer.BorderColor = GreyBorderColor.CGColor; } } void AddBorderToControl() { Control.Layer.CornerRadius = 3; Control.Layer.BorderWidth = 1; Control.Layer.BorderColor = GreyBorderColor.CGColor; } }
  • 25. Customization - Renderer public class PullToRefreshViewRenderer : VisualElementRenderer<PullToRefreshView> { UIRefreshControl refreshControl; protected override void OnElementChanged(ElementChangedEventArgs<PullToRefreshView> e) { base.OnElementChanged (e); var renderer = Subviews [0] as ListViewRenderer; if (renderer == null) return; refreshControl = new UIRefreshControl (); refreshControl.ValueChanged += OnRefreshingChanged; renderer.Control.AddSubview(refreshControl); UpdateIsRefreshing(); } }
  • 26. Customization - per-platform <OnPlatform x:TypeArguments="Font" Android="sans-serif,None,21" iOS="HelveticaNeue,None,16" x:Key="TitleFont"/> <Style x:Key="TitleLabel" TargetType="Label"> <Setter Property="AbsoluteLayout.LayoutBounds" Value="0,0,AutoSize,AutoSize" /> <Setter Property="AbsoluteLayout.LayoutFlags" Value="PositionProportional" /> <Setter Property="Font" Value="{StaticResource TitleFont}" /> <Setter Property="TextColor" Value="#333" /> </Style>
  • 27. MVVM <StackLayout> <Entry Text="{Binding Username}"/> <Entry Text="{Binding Password}"/> <Button Text="Login" Command="{Binding LoginCommand}"/> </StackLayout> public class LoginViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public Command LoginCommand { get; private set; } string _username; public string Username { get { return _username; } set { _username = value; NotifyPropertyChanged(); } } // continued… }
  • 28. Attached Properties / Triggers <Style x:Key="ButtonStyle" TargetType="Button"> <Setter Property="TextColor" Value="Black" /> <Setter Property="BorderWidth" Value="1" /> <Setter Property="BorderRadius" Value="3" /> <Setter Property="BackgroundColor" Value="{StaticResource ButtonBackgroundColor}" /> <Setter Property="BorderColor" Value="{StaticResource ButtonBorderColor}" /> <Setter Property="Font" Value="{StaticResource ButtonFont}" /> <Style.Triggers> <Trigger Property="controls:ButtonExtensions.IsPrimary" Value="True" TargetType="Button"> <Setter Property="BackgroundColor" Value="{StaticResource PrimaryBackgroundColor}" /> <Setter Property="BorderColor" Value="{StaticResource PrimaryBorderColor}" /> </Trigger> </Style.Triggers> </Style>
  • 29. Behaviors <Entry Placeholder="Enter a System.Double"> <Entry.Behaviors> <local:NumericValidationBehavior /> </Entry.Behaviors> </Entry> public class NumericValidationBehavior : Behavior<Entry> { protected override void OnAttachedTo(Entry entry) { entry.TextChanged += OnEntryTextChanged; base.OnAttachedTo(entry); } protected override void OnDetachingFrom(Entry entry) { entry.TextChanged -= OnEntryTextChanged; base.OnDetachingFrom(entry); } void OnEntryTextChanged(object sender, TextChangedEventArgs args) { double result; bool isValid = Double.TryParse (args.NewTextValue, out result); ((Entry)sender).TextColor = isValid ? Color.Default : Color.Red; } }
  • 30. - DependencyService - MessagingCenter - Navigation Other features
  • 31. - Are XF apps slower than native? Yes - Are XF apps bigger than native? Yes Speed / size redux
  • 32. - New or Existing product? - New or Existing team? - Resources vs user experience Should I use XF?
  • 33. - Mockups - Prototypes And even if you don’t...
  • 34. - One UI layout - Very customizable - Initial customization investment - Develop by feature - Very active development Good
  • 35. - Bugs, fix with renderers - Renderers have “internal” code - No XAML designer - Open source? Bad
  • 36. - Getting started: http://developer.xamarin.com/guides/cross-platform/getting_started/ - Licensing: https://store.xamarin.com/ - Samples: https://github.com/xamarin/monotouch-samples / https://github.com/xamarin/monodroid- samples - Forms documentation: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/ - Forms samples: https://github.com/xamarin/xamarin-forms-samples Resources

Editor's Notes

  1. Background: .NET / WPF / AngularJS Xamarin: 8 months ago Forms: 6 months ago Ordertracker: Customer - where is my order / Restaurant - where are my drivers
  2. iOS exposes CocoaTouch SDK (ex. UIKit) Android exposes Android SDK interacts with native types via JNI most of Mono.Android is just wrappers
  3. Native / Siloed
  4. Language / UI / Container Abandoned: Facebook / LinkedIn Problems: debugging, performance, animation Combination: Instagram - timeline, JUST EAT - checkout Cordova provides an abstraction over OS services like location
  5. Makes cross-platform applications easier
  6. No JIT
  7. interacts with native types via JNI most of Mono.Android is just wrappers
  8. SDK: Google Analytics / AWS-SDK iOS: binaries (.a) / headers (.h) + bindings Android: .jar + bindings Nuget: Autofac / JSON.Net PCL or Android/iOS specific C# code
  9. iOS: C++ / Swift faster , Objective-C slower Android: C++ faster , Davlik same Frameworks iOS - generics special case Xamarin Forms, a bit more so too.
  10. Dynamic Runtime Language - NO Generics - Of Course!
  11. iOS: storyboard, xib Android: layouts, drawables, styles WP: xaml
  12. iOS: storyboard, xib Android: layouts, drawables, styles WP: xaml
  13. iOS: storyboard, xib Android: layouts, drawables, styles WP: xaml
  14. Variation of patterns like MVC / MVP VM is a dataconverter between the view and model Goal is to remove all “code-behind” from .NET (WPF) Forms
  15. Variation of patterns like MVC / MVP VM is a dataconverter between the view and model Goal is to remove all “code-behind” from .NET (WPF) Forms
  16. DS: Service Locator pattern Static singleton (again) No constructor injection MC: Used internally by XF Static singleton Strange generic syntax
  17. For new team: start simple gain platform experience mix experienced with non-experienced code sharing vs custom UI