Développement cross-plateforme sans compromis avec Xamarin

Post on 16-Jul-2015

279 views 0 download

Transcript of Développement cross-plateforme sans compromis avec Xamarin

#XamarinFR

1

@micjames6

mike@xamarin.com

micjames.co.uk

Mike JamesDeveloper Evangelist, Xamarin Inc

Twitter

Email

Web

The best language for Windows development.

Modern Features • Advanced Tools • Proven Libraries • Large Community • Statically Typed

#

Xamarin makes C# the best language for mobile development.

Native Code Generation • Platform API Bindings • Code Sharing • Visual Studio

+#

Xamarin ‘embraced and extended’ .NET

Architecting

Mobile Apps

Silo

Approach

Build Apps

Multiple Times

Write Once,

Run Anywhere

Approach

Lowest

Common

Denominator

Xamarin’s Unique Approach

Native With

Code Sharing

Windows APIs

iOS APIs | 100% Coverage

Android APIs | 100% Coverage

Anything you can do in Objective-C, Swift, or Java

can be done in C# with Xamarin using Visual Studio

C# runs on 2.6 Billion Devices

How

Xamarin

Works

C# + .NET Runtime

Native UI

Native Performance

Portable Class Libraries

Xamarin.Forms

With Xamarin.Forms:

more code-sharing, native controlsTraditional Xamarin approach

Shared UI Code

Xamarin.Forms

Quickly and easily build native

user interfaces using shared code

Xamarin.Forms elements map to

native controls and behaviours

Mix-and-match Xamarin.Forms

with native APIs

Shared UI Code

What’s Included

40+ Pages, Layouts, and Controls

Build from code behind or XAML

Two-way Data Binding

Navigation

Animation API

Dependency Service

Messaging Center

Shared UI Code

Pages

Content MasterDetail Navigation Tabbed Carousel

Layouts

Stack Absolute Relative Grid ContentView ScrollView Frame

Controls

ActivityIndicator BoxView Button DatePicker Editor

Entry Image Label ListView Map

OpenGLView Picker ProgressBar SearchBar Slider

Stepper TableView TimePicker WebView EntryCell

ImageCell SwitchCell TextCell ViewCell

• Not for all types of apps

• Is your app very customised?

• Great for data driven apps

• Utility apps

• Also supports maps

Considerations

24

Platform-specific

projects act as

"host" to create

native application

Portable Class Library or

Shared Project used to

hold shared code that

defines UI and logic

Project Structure

Pages

• Single screen of content

• ContentPage holds one visual element

ContentPage

Control

Content property

Layouts

• Layouts handle child elements

• Layouts come in two types: managed and unmanaged

ContentPage

Layout

Content property

Control

Control

Children

Control

Demo - Creating User Interfaces

28

Providing Behaviour

var entry = new Entry

{

Placeholder = "Enter text",

Keyboard = Keyboard.Email

};

entry.TextChanged += (sender, e) => {

// Input changed

};

Controls expose properties to alter visualisation

Controls expose events to provide interactive behaviour

Demo - Adding Behaviour

30

Model-View-ViewModel

ModelView ViewModel

How to display

information

What to display

Flow of interaction

Business Logic

Data objects

Events

DataData

31

Model-View-ViewModel

ModelView ViewModel

Xamarin.Forms Data

Binding

Events

Data

32

Data Binding

33

Data Binding

34

Data Binding

35

Data Binding

Demo - Stocks

38

Extensibility

• Custom Renderer• Easily subclass any control you wish to customize

• Add your own custom controls• Add custom bindable properties

http://developer.xamarin.com/guides/cross-

platform/xamarin-forms/custom-renderer/

39

Extensibility

Standard Entry Control

40

Extensibility

Step 1: Custom Xamarin.Forms Control

41

Extensibility

Step 2: Use Custom Control in Shared Pages

42

Extensibility

Step 3: Implement Custom Renderer

43

Extensibility

Step 4: Export Renderer

44

Extensibility

Dependency ServiceAllows shared code to access platform-specific SDK features via an Interface

Implementation

45

Summary

• Cross platform apps the easy way

• Powerful layout functionality

• Many built in controls

• Extensible

46

Charles Petzold

Xamarin

Read the book

Learn more

Unrivalled Mobile Development Training

Live unlimited mobile development training from mobile experts,

in your time-zone, on your schedule and as often as you'd like

xamarin.com/university

Get Started Today: xamarin.com/download