create cross-platform apps using portable class libraries

22
Create cross-platform apps using Portable Class Libraries Daniel Plaisted .NET Framework daplaist@microsoft. com @dsplaisted 3-004

Upload: zubeda

Post on 23-Feb-2016

36 views

Category:

Documents


0 download

DESCRIPTION

Create cross-platform apps using Portable Class Libraries. Daniel Plaisted .NET Framework [email protected] @ dsplaisted 3-004. What we’ll learn. Share code across platforms with Portable Class Libraries Use the MVVM pattern to write cross-platform apps - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Create cross-platform apps using Portable Class Libraries

Create cross-platform apps using Portable Class LibrariesDaniel Plaisted.NET [email protected] @dsplaisted3-004

Page 2: Create cross-platform apps using Portable Class Libraries

What we’ll learnShare code across platforms with Portable Class LibrariesUse the MVVM pattern to write cross-platform appsPut models and view models in portable librariesCreate platform-specific viewsCreate portable abstractions for non-portable functionalityImplement the abstractions for each platform you targetConsider using a service locator or IoC container to hook up implementations

How to create cross-platform apps that take full advantage

of platform-specific features while maximizing code reuse for the rest of your app

Page 3: Create cross-platform apps using Portable Class Libraries

.NET platform proliferation

Page 4: Create cross-platform apps using Portable Class Libraries

Project proliferation

Page 5: Create cross-platform apps using Portable Class Libraries

One sourceOne projectOne binary

Multiple platforms!

Portable Class Libraries

Page 6: Create cross-platform apps using Portable Class Libraries

Portable platform/feature matrix

What can I use and where?

Page 8: Create cross-platform apps using Portable Class Libraries

Model-View-ViewModel (MVVM)ViewsHow to display informationWritten in XAML

View ModelsWhat information to displayFlow of interaction

ModelsData objectsBusiness logicEtc.

Model

View Model

View Platform-specific

PortableReferences

Databinds

Page 9: Create cross-platform apps using Portable Class Libraries

Cross-platform app architecture

Startup

Views

Windows Store App

Platform specific functionality

View Models

Models

Portable Class Library

Platform functionality abstractions

Startup

Views

Windows Phone App

Platform specific functionality

Reference Reference

Page 10: Create cross-platform apps using Portable Class Libraries

Creating a simple cross-platform app

Demo

Page 11: Create cross-platform apps using Portable Class Libraries

Pass dependencies in from app codeService locator/platform abstractionIoC container

Hooking platform-specifics to portable code

Page 12: Create cross-platform apps using Portable Class Libraries

public class ServiceLocator{ public static IFileStorage FileStorage { get; set; } public static IPhotoChooser PhotoChooser { get; set; }}

Simple service locator

Page 13: Create cross-platform apps using Portable Class Libraries

What we’re learningShare code across platforms with Portable Class LibrariesUse the MVVM pattern to write cross-platform appsPut models and view models in portable librariesCreate platform-specific viewsCreate portable abstractions for non-portable functionalityImplement the abstractions for each platform you targetConsider using a service locator or IoC container to hook up implementations

How to create cross-platform apps that take full advantage

of platform-specific features while maximizing code reuse for the rest of your app

Page 14: Create cross-platform apps using Portable Class Libraries

Contoso Helpdesk

Demo

Page 15: Create cross-platform apps using Portable Class Libraries

NavigationIoCAsyncAzure Service Bus

More patterns for portable apps

Page 16: Create cross-platform apps using Portable Class Libraries

Azure service bus

MSDN Magazine:Create a Continuous Client Using Portable Class Libraries

Page 18: Create cross-platform apps using Portable Class Libraries

Demo

Twitter Search

Page 19: Create cross-platform apps using Portable Class Libraries

In review: what we learnedShare code across platforms with Portable Class LibrariesUse the MVVM pattern to write cross-platform appsPut models and view models in portable librariesCreate platform-specific viewsCreate portable abstractions for non-portable functionalityImplement the abstractions for each platform you targetConsider using a service locator or IoC container to hook up implementations

How to create cross-platform apps that take full advantage

of platform-specific features while maximizing code reuse for the rest of your app

Page 20: Create cross-platform apps using Portable Class Libraries

• How to Leverage your Code across WP8 and Windows 8 – 3-043

• Designing awesome XAML apps in Visual Studio and Blend for Windows 8 and Windows Phone 8 – 3-006

• The Evolution of .NET – 3-016

• Deep Dive into the Kernel of .NET on Windows Phone 8 – 3-005

Related Sessions

Page 21: Create cross-platform apps using Portable Class Libraries

http://tinyurl.com/Build2012PCL

Additional Resources

Please submit session evals on the Build Windows 8 App or at http://aka.ms/BuildSessions

Page 22: Create cross-platform apps using Portable Class Libraries

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.