SlideShare a Scribd company logo
1 of 35
Xamarin.Forms
Hi!
Marcel de Vries
• @marcelv
• marcel.devries@infosupport.com
Marco Kuiper
• @marcofolio
• marco.kuiper@infosupport.com
Before
80% shared code
20% OS specific
Meet Xamarin.Forms
The promise
99,9% shared code
0,1% OS specific
Pages
ContentPage MasterDetailPage NavigationPage TabbedPage CarouselPage
Layouts
AbsoluteLayoutStackLayout RelativeLayout GridLayout ContentView ScrollView Frame
Views
Cheat Sheet http://tinyurl.com/x
amarin-forms
Cheat Sheet http://tinyurl.com/x
amarin-forms
Cheat Sheet http://tinyurl.com/x
amarin-forms
But how? C#
But how? XAML
ViewModel
Data binding
Case Study
ISKE App (Yes a new version is on its way!)
Xamarin forms Architecture
• The Forms code is a thin wrapper that tanslates XAML to the native
equivalents on the platform
Renderer
UILabel TextView TextBlock
LabelRendererLabelRendererLabelRenderer
Xamarin forms Architecture
• The Forms code is a thin wrapper that tanslates XAML to the native
equivalents on the platform
Renderer
UITableView ListView LongListSelector
ListViewRendererListViewRenderer ListViewRenderer
Challenges
• How to translate a specific
UI widget created in our
previous app?
• Custom controls to the
rescue
Custom controls
• Create a class that contains the properties you need to bind on the screen
• E.g. Date time String containing the Day, Month and Time
public class DateTile : View
{
public static readonly BindableProperty DateOnTileProperty =
BindableProperty.Create<DateTile, string>(p => p.DateOnTile,
DateTime.Now.ToString("dd MMM hh:mm"));
//Gets or sets the color of the progress bar
public string DateOnTile
{
get { return (string)GetValue(DateOnTileProperty); }
set { SetValue(DateOnTileProperty, value); }
}
}
Inherit from the control type that provides the
basics of your custom control
Custom controls
• Create a renderer for each platform (use the cheat sheet to know which
renderer to use)
public class DateTileRenderer : ViewRenderer<DateTile,UIView>
{
protected override void OnElementChanged(ElementChangedEventArgs<DateTile> e)
{
base.OnElementChanged (e);
if (e.OldElement != null || this.Element == null)
return;
var Control = new UIView(new RectangleF(0,0,60,78));
this.AddSubview(Control);
this.SetNativeControl(Control);
}
protected override void OnElementPropertyChanged(object sender,System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if(e.PropertyName == DateTile.DateOnTileProperty.PropertyName)
{
var control = (DateTile)sender;
// insert your code here to show the updated control (in my case update the labels)
this.SetNativeControl(yourcustomNativeInstance);
}
}
Initially called to create the control
Called when a property on your control
gets changed
Custom controls that contains a set of other controls
• E.g. a control wrapping a row in a table and is nothing mre then a
composition of other controls
• In this case you can override the behavior in the shared code in stead of the
custom renderer per platform
• Construct the abstract control in code on creations
• Implement the OnPropertyChanged in the generic custom control
Platform specific (Alternative to #ifdef)
• C#:
Device.OnPlatform(
iOS: () => box.Padding = new Thickness (20, 0),
Android: () => box.Padding = new Thickness (20)
);
• XAML:
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness">
<OnPlatform.iOS>20, 0</OnPlatform.iOS>
<OnPlatform.Android>20</OnPlatform.Android>
</OnPlatform>
</StackLayout.Padding>
More than forms
Messaging Center
Messaging
CenterMaster
Subscribes
Receives message
Detail
Sends message
Animations
• Cross-platform animations
• Async / Await API
Dependency Service
Access to Native Features
Three steps
1. Interface
2. Registration
3. Location
Conclusion
Visual Studio vs Xamarin Studio
• Windows Phone support only in visual studio
and only Windows 8 Silverlight (no universal apps)
• Xamarin studio will not load Windows Phone apps
• Sometimes visual studio injects 2013 version in SLN
header -> Will render solution unusable in Xamarin Studio
• Xamarin studio now also supports NuGet
Arguably better implemented then in VS
• On Pull from GIT, Xamarin studio does not update the
solution, you need to manually Unload and reload
• Visual studio linker sometimes operated more aggressive
resulting in runtime error on missing libraries
• Image suffers from this problem at the moment
• Assembly redirects do not solve the issue, neither do the
auto generate redirects
• Shared Libraries are not implemented consistent cross
Ide’s
• Xamarin studio allows more-> results in crashed of VS
XAML
• Is not a 1:1 translation, since you need to work with new concepts
• StackPanel -> StackLayout
• TextBlock -> Label
• Etc.
• No UI editor
• XAML intellisense is non existent
• I first code in C# with Intellisense, then I translate it to Xaml
PCL vs Shared
• Shared projects are great but:
• They are clearly a 1.0 version
• No feature parity between VS and Xamarin studio
• Lot of stuff is allowed in Xamarin studio, that will break VS
• After a couple of tries, I moved to PCL
• Way more mature at the moment
• Did not hit any nasty issues yet
• When to use what (When it works eventualy)?
• In theory I would propose: Use Share Libs for the stuff you want to share
between platforms but you don’t want to reuse cross projects
• Use PCL when you create stuff that you would share cross projects
• Better, also bundle it as NuGet package in your build
Silver bullet ?
• At first we where very skeptical about this solution
• We always believed the Native UI on each platform is a key thing to good
apps
• Xamarin seems to have found a way to get best of both worlds
• Share cross platforms, but translate to native device equivalents
• This gives us both the native feel and the best performance
• The 99% looks nice, but:
• Remember the experience is counts not the % of code sharing you got!
• You will need (at least at the moment) custom renderers to fix UI things on
different platforms (e.g. set transparent color so you can have an image
background)
Thank you!

More Related Content

What's hot

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 4Xamarin
 
Developing and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin StudioDeveloping and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin StudioXamarin
 
Highlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conferenceHighlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conferenceChristopher Miller
 
Introduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideIntroduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideJames Montemagno
 
Introduction to Xamarin.Forms
Introduction to Xamarin.FormsIntroduction to Xamarin.Forms
Introduction to Xamarin.FormsXamarin
 
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 StudioXamarin
 
Introduction to Xamarin
Introduction to XamarinIntroduction to Xamarin
Introduction to XamarinBrian Anderson
 
Your First Xamarin.Forms App
Your First Xamarin.Forms AppYour First Xamarin.Forms App
Your First Xamarin.Forms AppCraig Dunn
 
Hybrid Mobile App Development - Xamarin
Hybrid Mobile App Development - XamarinHybrid Mobile App Development - Xamarin
Hybrid Mobile App Development - XamarinDeepu S Nath
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Xamarin
 
Xamarin overview droidcon.tn
Xamarin overview   droidcon.tnXamarin overview   droidcon.tn
Xamarin overview droidcon.tnHoussem Dellai
 
Introduction to Xamarin.Forms
Introduction to Xamarin.FormsIntroduction to Xamarin.Forms
Introduction to Xamarin.FormsJames Montemagno
 
Introduction to Xamarin 2.0
Introduction to Xamarin 2.0Introduction to Xamarin 2.0
Introduction to Xamarin 2.0Xamarin
 
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
State of Union: Xamarin & Cross-Platform .NET in 2016 and BeyondState of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
State of Union: Xamarin & Cross-Platform .NET in 2016 and BeyondNick Landry
 
Getting Started with iOS & Android Development Using Xamarin & Visual Studio
Getting Started with iOS & Android Development Using Xamarin & Visual StudioGetting Started with iOS & Android Development Using Xamarin & Visual Studio
Getting Started with iOS & Android Development Using Xamarin & Visual StudioMark Arteaga
 
Couchbase Workshop - Introduction to Xamarin
Couchbase Workshop - Introduction to XamarinCouchbase Workshop - Introduction to Xamarin
Couchbase Workshop - Introduction to XamarinJames Montemagno
 

What's hot (20)

Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
 
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
 
Developing and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin StudioDeveloping and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin Studio
 
Highlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conferenceHighlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conference
 
Introduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideIntroduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet Westide
 
Introduction to Xamarin.Forms
Introduction to Xamarin.FormsIntroduction to Xamarin.Forms
Introduction to Xamarin.Forms
 
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
 
Your First Xamarin.Forms App
Your First Xamarin.Forms AppYour First Xamarin.Forms App
Your First Xamarin.Forms App
 
Hybrid Mobile App Development - Xamarin
Hybrid Mobile App Development - XamarinHybrid Mobile App Development - Xamarin
Hybrid Mobile App Development - Xamarin
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
 
Xamarin overview droidcon.tn
Xamarin overview   droidcon.tnXamarin overview   droidcon.tn
Xamarin overview droidcon.tn
 
Introduction to Xamarin.Forms
Introduction to Xamarin.FormsIntroduction to Xamarin.Forms
Introduction to Xamarin.Forms
 
Introduction to Xamarin 2.0
Introduction to Xamarin 2.0Introduction to Xamarin 2.0
Introduction to Xamarin 2.0
 
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
State of Union: Xamarin & Cross-Platform .NET in 2016 and BeyondState of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
 
Evolve 2014
Evolve 2014Evolve 2014
Evolve 2014
 
Getting Started with iOS & Android Development Using Xamarin & Visual Studio
Getting Started with iOS & Android Development Using Xamarin & Visual StudioGetting Started with iOS & Android Development Using Xamarin & Visual Studio
Getting Started with iOS & Android Development Using Xamarin & Visual Studio
 
Evolve 2016
Evolve 2016Evolve 2016
Evolve 2016
 
Couchbase Workshop - Introduction to Xamarin
Couchbase Workshop - Introduction to XamarinCouchbase Workshop - Introduction to Xamarin
Couchbase Workshop - Introduction to Xamarin
 

Viewers also liked

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 DevOpsXamarin
 
Deep Dive in Xamarin.Forms
Deep Dive in Xamarin.FormsDeep Dive in Xamarin.Forms
Deep Dive in Xamarin.FormsJames Montemagno
 
What's new in Xamarin.Forms?
What's new in Xamarin.Forms?What's new in Xamarin.Forms?
What's new in Xamarin.Forms?James Montemagno
 
Cross-Platform Mobile Development with PhoneGap-Vince Bullinger
Cross-Platform Mobile Development with PhoneGap-Vince BullingerCross-Platform Mobile Development with PhoneGap-Vince Bullinger
Cross-Platform Mobile Development with PhoneGap-Vince BullingerMobile March
 
Wearables with C# and Xamarin
Wearables with C# and XamarinWearables with C# and Xamarin
Wearables with C# and XamarinCraig Dunn
 
Native cross-platform mobile apps with C# and Xamarin.Forms
Native cross-platform mobile apps with C# and Xamarin.FormsNative cross-platform mobile apps with C# and Xamarin.Forms
Native cross-platform mobile apps with C# and Xamarin.FormsPeter Major
 
Cross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinCross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinPuja Pramudya
 
Navigation in Xamarin.Forms
Navigation in Xamarin.FormsNavigation in Xamarin.Forms
Navigation in Xamarin.FormsKym Phillpotts
 
Codemotion 2015: UI Tests, Test Cloud y CI con Apps Xamarin
Codemotion 2015: UI Tests, Test Cloud y CI con Apps XamarinCodemotion 2015: UI Tests, Test Cloud y CI con Apps Xamarin
Codemotion 2015: UI Tests, Test Cloud y CI con Apps XamarinJavier Suárez Ruiz
 
Mobile Banking Apps with Xamarin
Mobile Banking Apps with XamarinMobile Banking Apps with Xamarin
Mobile Banking Apps with XamarinXpand IT
 
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 XamarinXamarin
 
Say hello to Xamarin 3
Say hello to Xamarin 3Say hello to Xamarin 3
Say hello to Xamarin 3Xamarin
 
Multi-threaded CoreData Done Right
Multi-threaded CoreData Done RightMulti-threaded CoreData Done Right
Multi-threaded CoreData Done Rightmorrowa_de
 
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
 
Building Your First Xamarin.Forms App
Building Your First Xamarin.Forms AppBuilding Your First Xamarin.Forms App
Building Your First Xamarin.Forms AppXamarin
 

Viewers also liked (20)

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
 
Deep Dive in Xamarin.Forms
Deep Dive in Xamarin.FormsDeep Dive in Xamarin.Forms
Deep Dive in Xamarin.Forms
 
Xamarin 研究
Xamarin 研究Xamarin 研究
Xamarin 研究
 
What's new in Xamarin.Forms?
What's new in Xamarin.Forms?What's new in Xamarin.Forms?
What's new in Xamarin.Forms?
 
Cross-Platform Mobile Development with PhoneGap-Vince Bullinger
Cross-Platform Mobile Development with PhoneGap-Vince BullingerCross-Platform Mobile Development with PhoneGap-Vince Bullinger
Cross-Platform Mobile Development with PhoneGap-Vince Bullinger
 
Wearables with C# and Xamarin
Wearables with C# and XamarinWearables with C# and Xamarin
Wearables with C# and Xamarin
 
Xamarin forms en el mundo real
Xamarin forms en el mundo realXamarin forms en el mundo real
Xamarin forms en el mundo real
 
Xamarin Forms
Xamarin FormsXamarin Forms
Xamarin Forms
 
Native cross-platform mobile apps with C# and Xamarin.Forms
Native cross-platform mobile apps with C# and Xamarin.FormsNative cross-platform mobile apps with C# and Xamarin.Forms
Native cross-platform mobile apps with C# and Xamarin.Forms
 
Cross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinCross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with Xamarin
 
Navigation in Xamarin.Forms
Navigation in Xamarin.FormsNavigation in Xamarin.Forms
Navigation in Xamarin.Forms
 
Intro to Xamarin
Intro to XamarinIntro to Xamarin
Intro to Xamarin
 
Codemotion 2015: UI Tests, Test Cloud y CI con Apps Xamarin
Codemotion 2015: UI Tests, Test Cloud y CI con Apps XamarinCodemotion 2015: UI Tests, Test Cloud y CI con Apps Xamarin
Codemotion 2015: UI Tests, Test Cloud y CI con Apps Xamarin
 
Mobile Banking Apps with Xamarin
Mobile Banking Apps with XamarinMobile Banking Apps with Xamarin
Mobile Banking Apps with Xamarin
 
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
 
Introducción a Xamarin
Introducción a XamarinIntroducción a Xamarin
Introducción a Xamarin
 
Say hello to Xamarin 3
Say hello to Xamarin 3Say hello to Xamarin 3
Say hello to Xamarin 3
 
Multi-threaded CoreData Done Right
Multi-threaded CoreData Done RightMulti-threaded CoreData Done Right
Multi-threaded CoreData Done Right
 
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...
 
Building Your First Xamarin.Forms App
Building Your First Xamarin.Forms AppBuilding Your First Xamarin.Forms App
Building Your First Xamarin.Forms App
 

Similar to Xamarin.Forms

App innovationcircles xamarin
App innovationcircles xamarinApp innovationcircles xamarin
App innovationcircles xamarinMohit Chhabra
 
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 developmentGill Cleeren
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinPranav Ainavolu
 
Introduction to Xamarin.Forms
Introduction to Xamarin.FormsIntroduction to Xamarin.Forms
Introduction to Xamarin.FormsBrad Pillow
 
NET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptx
NET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptxNET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptx
NET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptxLuis Beltran
 
WebAssembly and .NET
WebAssembly and .NETWebAssembly and .NET
WebAssembly and .NETJoanna Lamch
 
extending-and-optimizing-xamarin-forms-apps
extending-and-optimizing-xamarin-forms-appsextending-and-optimizing-xamarin-forms-apps
extending-and-optimizing-xamarin-forms-appsMatthew Soucoup
 
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 MvvmCrossFlavius-Radu Demian
 
Browser Developer Tools for APEX Developers
Browser Developer Tools for APEX DevelopersBrowser Developer Tools for APEX Developers
Browser Developer Tools for APEX DevelopersChristian Rokitta
 
Wpf-Xaml And Layout Basics
Wpf-Xaml And Layout BasicsWpf-Xaml And Layout Basics
Wpf-Xaml And Layout BasicsRobin Aggarwal
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...InfinIT - Innovationsnetværket for it
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)Dilawar Khan
 
Cross-Platform Mobile Development using Visual Studio and Xamarin
Cross-Platform Mobile Development using Visual Studio and XamarinCross-Platform Mobile Development using Visual Studio and Xamarin
Cross-Platform Mobile Development using Visual Studio and XamarinShravan Kumar Kasagoni
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin formsSolTech, Inc.
 
Xamarin - Victim of Phonegap’s horrible reputation
Xamarin - Victim of Phonegap’s horrible reputationXamarin - Victim of Phonegap’s horrible reputation
Xamarin - Victim of Phonegap’s horrible reputationGabor Wnuk
 
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014FalafelSoftware
 

Similar to Xamarin.Forms (20)

App innovationcircles xamarin
App innovationcircles xamarinApp innovationcircles xamarin
App innovationcircles 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
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with Xamarin
 
Introduction to Xamarin.Forms
Introduction to Xamarin.FormsIntroduction to Xamarin.Forms
Introduction to Xamarin.Forms
 
Mini .net conf 2020
Mini .net conf 2020Mini .net conf 2020
Mini .net conf 2020
 
NET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptx
NET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptxNET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptx
NET Conf Bhubaneswar - Migrating your Xamarin.Forms app to .NET MAUI.pptx
 
WebAssembly and .NET
WebAssembly and .NETWebAssembly and .NET
WebAssembly and .NET
 
extending-and-optimizing-xamarin-forms-apps
extending-and-optimizing-xamarin-forms-appsextending-and-optimizing-xamarin-forms-apps
extending-and-optimizing-xamarin-forms-apps
 
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
 
Intro to .NET and Core C#
Intro to .NET and Core C#Intro to .NET and Core C#
Intro to .NET and Core C#
 
Browser Developer Tools for APEX Developers
Browser Developer Tools for APEX DevelopersBrowser Developer Tools for APEX Developers
Browser Developer Tools for APEX Developers
 
Wpf-Xaml And Layout Basics
Wpf-Xaml And Layout BasicsWpf-Xaml And Layout Basics
Wpf-Xaml And Layout Basics
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)
 
Cross-Platform Mobile Development using Visual Studio and Xamarin
Cross-Platform Mobile Development using Visual Studio and XamarinCross-Platform Mobile Development using Visual Studio and Xamarin
Cross-Platform Mobile Development using Visual Studio and Xamarin
 
SDWest2005Goetsch
SDWest2005GoetschSDWest2005Goetsch
SDWest2005Goetsch
 
Intro to Xamarin
Intro to XamarinIntro to Xamarin
Intro to Xamarin
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
 
Xamarin - Victim of Phonegap’s horrible reputation
Xamarin - Victim of Phonegap’s horrible reputationXamarin - Victim of Phonegap’s horrible reputation
Xamarin - Victim of Phonegap’s horrible reputation
 
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
 

More from marcofolio

NDC Oslo: Turn specs into high quality apps
NDC Oslo: Turn specs into high quality appsNDC Oslo: Turn specs into high quality apps
NDC Oslo: Turn specs into high quality appsmarcofolio
 
Turn specs into high quality apps
Turn specs into high quality appsTurn specs into high quality apps
Turn specs into high quality appsmarcofolio
 
Weaving Cognitive and Azure Services
Weaving Cognitive and Azure ServicesWeaving Cognitive and Azure Services
Weaving Cognitive and Azure Servicesmarcofolio
 
Give your Apps a Personal Touch with Cognitive Services
Give your Apps a Personal Touch with Cognitive ServicesGive your Apps a Personal Touch with Cognitive Services
Give your Apps a Personal Touch with Cognitive Servicesmarcofolio
 
Turn specs into high quality apps
Turn specs into high quality appsTurn specs into high quality apps
Turn specs into high quality appsmarcofolio
 
PechaKucha - "Siri, start presentation 'HomeKit'"
PechaKucha - "Siri, start presentation 'HomeKit'"PechaKucha - "Siri, start presentation 'HomeKit'"
PechaKucha - "Siri, start presentation 'HomeKit'"marcofolio
 

More from marcofolio (6)

NDC Oslo: Turn specs into high quality apps
NDC Oslo: Turn specs into high quality appsNDC Oslo: Turn specs into high quality apps
NDC Oslo: Turn specs into high quality apps
 
Turn specs into high quality apps
Turn specs into high quality appsTurn specs into high quality apps
Turn specs into high quality apps
 
Weaving Cognitive and Azure Services
Weaving Cognitive and Azure ServicesWeaving Cognitive and Azure Services
Weaving Cognitive and Azure Services
 
Give your Apps a Personal Touch with Cognitive Services
Give your Apps a Personal Touch with Cognitive ServicesGive your Apps a Personal Touch with Cognitive Services
Give your Apps a Personal Touch with Cognitive Services
 
Turn specs into high quality apps
Turn specs into high quality appsTurn specs into high quality apps
Turn specs into high quality apps
 
PechaKucha - "Siri, start presentation 'HomeKit'"
PechaKucha - "Siri, start presentation 'HomeKit'"PechaKucha - "Siri, start presentation 'HomeKit'"
PechaKucha - "Siri, start presentation 'HomeKit'"
 

Xamarin.Forms

  • 2. Hi! Marcel de Vries • @marcelv • marcel.devries@infosupport.com Marco Kuiper • @marcofolio • marco.kuiper@infosupport.com
  • 5. The promise 99,9% shared code 0,1% OS specific
  • 14.
  • 16. ISKE App (Yes a new version is on its way!)
  • 17. Xamarin forms Architecture • The Forms code is a thin wrapper that tanslates XAML to the native equivalents on the platform Renderer UILabel TextView TextBlock LabelRendererLabelRendererLabelRenderer
  • 18. Xamarin forms Architecture • The Forms code is a thin wrapper that tanslates XAML to the native equivalents on the platform Renderer UITableView ListView LongListSelector ListViewRendererListViewRenderer ListViewRenderer
  • 19. Challenges • How to translate a specific UI widget created in our previous app? • Custom controls to the rescue
  • 20. Custom controls • Create a class that contains the properties you need to bind on the screen • E.g. Date time String containing the Day, Month and Time public class DateTile : View { public static readonly BindableProperty DateOnTileProperty = BindableProperty.Create<DateTile, string>(p => p.DateOnTile, DateTime.Now.ToString("dd MMM hh:mm")); //Gets or sets the color of the progress bar public string DateOnTile { get { return (string)GetValue(DateOnTileProperty); } set { SetValue(DateOnTileProperty, value); } } } Inherit from the control type that provides the basics of your custom control
  • 21. Custom controls • Create a renderer for each platform (use the cheat sheet to know which renderer to use) public class DateTileRenderer : ViewRenderer<DateTile,UIView> { protected override void OnElementChanged(ElementChangedEventArgs<DateTile> e) { base.OnElementChanged (e); if (e.OldElement != null || this.Element == null) return; var Control = new UIView(new RectangleF(0,0,60,78)); this.AddSubview(Control); this.SetNativeControl(Control); } protected override void OnElementPropertyChanged(object sender,System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if(e.PropertyName == DateTile.DateOnTileProperty.PropertyName) { var control = (DateTile)sender; // insert your code here to show the updated control (in my case update the labels) this.SetNativeControl(yourcustomNativeInstance); } } Initially called to create the control Called when a property on your control gets changed
  • 22. Custom controls that contains a set of other controls • E.g. a control wrapping a row in a table and is nothing mre then a composition of other controls • In this case you can override the behavior in the shared code in stead of the custom renderer per platform • Construct the abstract control in code on creations • Implement the OnPropertyChanged in the generic custom control
  • 23. Platform specific (Alternative to #ifdef) • C#: Device.OnPlatform( iOS: () => box.Padding = new Thickness (20, 0), Android: () => box.Padding = new Thickness (20) ); • XAML: <StackLayout.Padding> <OnPlatform x:TypeArguments="Thickness"> <OnPlatform.iOS>20, 0</OnPlatform.iOS> <OnPlatform.Android>20</OnPlatform.Android> </OnPlatform> </StackLayout.Padding>
  • 24.
  • 28. Dependency Service Access to Native Features Three steps 1. Interface 2. Registration 3. Location
  • 29.
  • 31. Visual Studio vs Xamarin Studio • Windows Phone support only in visual studio and only Windows 8 Silverlight (no universal apps) • Xamarin studio will not load Windows Phone apps • Sometimes visual studio injects 2013 version in SLN header -> Will render solution unusable in Xamarin Studio • Xamarin studio now also supports NuGet Arguably better implemented then in VS • On Pull from GIT, Xamarin studio does not update the solution, you need to manually Unload and reload • Visual studio linker sometimes operated more aggressive resulting in runtime error on missing libraries • Image suffers from this problem at the moment • Assembly redirects do not solve the issue, neither do the auto generate redirects • Shared Libraries are not implemented consistent cross Ide’s • Xamarin studio allows more-> results in crashed of VS
  • 32. XAML • Is not a 1:1 translation, since you need to work with new concepts • StackPanel -> StackLayout • TextBlock -> Label • Etc. • No UI editor • XAML intellisense is non existent • I first code in C# with Intellisense, then I translate it to Xaml
  • 33. PCL vs Shared • Shared projects are great but: • They are clearly a 1.0 version • No feature parity between VS and Xamarin studio • Lot of stuff is allowed in Xamarin studio, that will break VS • After a couple of tries, I moved to PCL • Way more mature at the moment • Did not hit any nasty issues yet • When to use what (When it works eventualy)? • In theory I would propose: Use Share Libs for the stuff you want to share between platforms but you don’t want to reuse cross projects • Use PCL when you create stuff that you would share cross projects • Better, also bundle it as NuGet package in your build
  • 34. Silver bullet ? • At first we where very skeptical about this solution • We always believed the Native UI on each platform is a key thing to good apps • Xamarin seems to have found a way to get best of both worlds • Share cross platforms, but translate to native device equivalents • This gives us both the native feel and the best performance • The 99% looks nice, but: • Remember the experience is counts not the % of code sharing you got! • You will need (at least at the moment) custom renderers to fix UI things on different platforms (e.g. set transparent color so you can have an image background)