Download presentation
Presentation is loading. Please wait.
Published byAugustine Williams Modified over 9 years ago
1
Building Windows phone, iOS and Android apps with C# Jaime Rodriguez Principal Evangelist, Microsoft
2
About me Why this talk…. 90s 2000 200 5 2008-Today Primitive s Productivit y UX Mobile Disclaimer
3
About me Why this talk…. 90s 2000 200 5 2008-Today Primitive s Productivit y UX Mobile Disclaimer I do not work for Xamarin Opinions are my own, not those of my day-job employer This space evolves very fast
4
Mobile Explosion Consumers are already mobile-first Business users are increasingly demanding mobile scenarios
5
How? #1 – Web Build a Mobile Website
6
How? #2 – Hybrid Web Put a Web App In the Store Native App Mobile Website
7
How? #3 – Cloned Native Build App Multiple Times
8
How? #4 – Shared Native Shared UI Code Build Natively and Share Code
9
With Visual Studio you can … Use a single development environment to target all devices Leverage your skills in your preferred language, C# or JavaScript Get the best developer experience for editing, building and debugging your applications
10
Why Native? Xamarin apps look and feel native because they are native Native User InterfacesNative API AccessNative Performance
11
Start with C# and BCL
12
… add Windows APIs 100% coverage
13
… or iOS APIs 100% coverage
14
… or Android APIs 100% coverage
15
demo Xamarin Development with Visual Studio
16
@implementation MSViewController - (void)viewDidLoad { [super viewDidLoad]; } - (IBAction)OnButtonDown:(id)sender { UIAlertView* view = [[UIAlertView alloc]init]; [view setTitle:@"Hello World"]; [view setMessage: @"How are you?”]; [view addButtonWithTitle:@"OK"]; [view show]; } @end public partial class iOSAppViewController : UIViewController { public iOSAppViewController (IntPtr handle) : base (handle){ } public override void ViewDidLoad (){ base.ViewDidLoad (); } partial void OnButtonDown (UIButton sender) { UIAlertView view = new UIAlertView(); view.Title = "Hello World" ; view.Message = "How are you? " ; view.AddButton ("OK"); view.Show(); } } iOS
17
public class MyActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { Button myBtn = (Button) this.findViewById( R.id.clickMe); myBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this) ; builder.setTitle( "Hello World").setMessage("How are you?").setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); }}).show(); }}); } } [Activity (Label = "AndroidApp", MainLauncher = true, Icon = "@drawable/icon")] public class MainActivity : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); Button button = FindViewById (Resource.Id.me); button.Click += delegate { AlertDialog.Builder builder = new AlertDialog.Builder (this ); AlertDialog dialog = null ; builder.SetTitle ( "Hello World").SetMessage ( "How are you").SetPositiveButton( "OK", delegate { dialog.Dismiss(); } ); dialog = builder.Show (); } ; } } Android
18
Anything you can do in Objective-C or Java can be done in C# with Xamarin using Visual Studio
19
Native Performance Xamarin.iOS does full Ahead Of Time (AOT) compilation to produce an ARM binary for Apple’s App Store. Xamarin.Android takes advantage of Just In Time (JIT) compilation on the Android device.
20
So far… Using C# BCL on iOS, Android and Windows Phone apps C# Bindings to iOS/Android Great tooling Editors Debugging Extensibility Potentially cumbersome code sharing as you write platform specific code ?
21
Sharing v1 Really?
22
Linked Files Compiler Directives
23
Code sharing v3
24
Share Code: Portable Class Libraries
25
NuGet
26
Shared Projects
27
UI: Xamarin + Xamarin.Forms With Xamarin.Forms: more code-sharing, native controls Traditional Xamarin approach Shared UI Code
28
40+ Pages, Layouts, and Controls Build from code behind or XAML Two-way Data Binding Navigation Animation API Dependency Service Messaging Center UI: Xamarin.Forms Shared UI Code
29
Pages ContentMasterDetail NavigationTabbedCarousel
30
Layouts Stack AbsoluteRelativeGrid ContentViewScrollView Frame
31
Controls ActivityIndicator BoxViewButtonDatePickerEditor EntryImageLabelListViewMap OpenGLViewPickerProgressBarSearchBarSlider StepperTableViewTimePicker WebViewEntryCell ImageCellSwitchCellTextCellViewCell
32
Xamarin Forms Mark-up (XAML 2009 spec) Data binding & Data Templates Markup Extensions Resources Dictionaries
33
Xamarin Forms Platform Features Page.DisplayAlert UI Thread marshalling Timers Xamarin.Forms.Maps Platform code via OnPlatform and DependencyService.Get
34
demo Hacking away with Xamarin and Visual Studio
35
Tips & Tricks Personal Observations & Lessons learned
36
Ramp-up & Mastery To be successful using C# on iOS, Android, and Windows Phone, you still have to know how to code for these platforms
37
How I learned native…
38
How I learned Xamarin…
39
Sharing code… what should you use? a)PCL b)Shared Projects c)partial classes d)C# extensions e)All of the above
40
UI Patterns & Tips Separate your concerns Declarative XAML MVVM is not required Use OnPlatform for platform specific code Use ContentPage + layout panels for dynamic resolution
41
Connect to the cloud: Microsoft Azure http://azure.microsoft.com/en-us/documentation/services/mobile-services/
42
Memory & Garbage Collection iOS Uses AOT (Ahead of Time) compiler Two GCs: default (Boehm) or Sgen Android Uses Sgen GC Windows Phone Uses.NET GC, http://developer.xamarin.com/guides/cross-platform/application_fundamentals/memory_perf_best_practices/ http://msdn.microsoft.com/en-us/library/ms973837.aspx
43
Performance Is usually not a problem Use native tools to measure iOS: Instruments Android: Device Monitor’s Allocation Manager Windows Phone: Visual Studio, Windows Phone Power tools, Graphics Diagnostics
44
For gamers
45
Closing: Mobile app development with C# Familiar Productive Highly reusable Empowering Built on a solid and extensible foundation
47
Want to win a free Xamarin license? 1.Download free version of Xamarin Studio … 2.Create a small Hello World Project on at least two of the three platforms: Windows Phone, Android, iOS. 3.Tweet a link to your project to @jaimerodriguez before October 10 th at noon PST 4.One random submission will be selected….and a coupon for free license will be emailed
48
Gracias!!! Aqui estoy los tres dias! @jaimerodriguez jaimer@microsoft.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.