Developing for Windows Phone 8 and Windows 8

38
Dave Bost Technical Evangelist, Windows Phone http://davebost.com @davebost October 1st 2012 Cross Development Windows 8 and Windows Phone 8

description

 

Transcript of Developing for Windows Phone 8 and Windows 8

Page 1: Developing for Windows Phone 8 and Windows 8

Dave Bost

Technical Evangelist, Windows

Phone

http://davebost.com

@davebost

October 1st 2012

Cross DevelopmentWindows 8 and Windows Phone 8

Page 2: Developing for Windows Phone 8 and Windows 8

Launch your App or Game in 30 days

Generation App Online training and tips from insiders App and Game dev content Tele-support with a Windows 8 architect Exclusive one-on-one WinRT and Windows UX

design consultation

30 Days to Launch

Learn. Build. Publish.

http://aka.ms/FreeBeer

Page 3: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential3

• Linked files

• #if conditionals

• Using Extension methods to bridge implementation differences

• MVVM

• Portable Class Libraries

• A common user experience bringing high-quality experiences to the user.

Best Practices for Windows 8 / Windows Phone 8

Page 4: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential4

Common Structure

Windows 8 Windows Phone 8

Page 5: Developing for Windows Phone 8 and Windows 8

Common APIs in Windows 8 and Windows Phone 8

Page 6: Developing for Windows Phone 8 and Windows 8

Your appsYour way

Windows Phone 8 Developer Platform

XAML Apps Direct3D Apps

XAML Maps Geolocation Sensors In-App Purchase Direct3D

HTML XML Threading Touch Speech XAudio2

Phone Features Push Camera Video Proximity Media

Foundation

Calendar Wallet Contacts Core Types VoIP STL

Multitasking Live Tiles Memory Async Enterprise CRT

C# and VB C#, VB, and C++ C++

File system, Networking, Graphics, Media

Core Operating System

Page 7: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential7

“Add as Link”

Page 8: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential8

“Add as Link”

Windows 8 Windows Phone 8

Page 9: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential9

Common APIs

Common

Base Class Library

Hardware

Storage (Files and Folders)

Different

Launchers and Choosers

Sharing APIs

Page 10: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential10

#if Conditional Blocks

Windows 8#if NETFX_COREDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {#endif

#if WINDOWS_PHONEDeployment.Current.Dispatcher.BeginInvoke(() => {#endif

Windows Phone 8

Page 11: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential11

Threading

Windows 8 AND Windows Phone 8#if NETFX_COREDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {#elseDeployment.Current.Dispatcher.BeginInvoke(() => {#endif double _accelX = args.Reading.AccelerationX; double _accelY = args.Reading.AccelerationY;

Page 12: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential12

Web Service

Page 13: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential13

HttpWebResponse and HttpWebRequest

Windows 8var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);

HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();

// retrieve data using StreamReader

Page 14: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential14

HttpWebResponse and HttpWebRequest

Windows Phone 8var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);request.BeginGetResponse(new AsyncCallback(AutoCompleteCallback), request);}

private void AutoCompleteCallback(IAsyncResult callback){ HttpWebRequest request = (HttpWebRequest)callback.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(callback); // retrieve data using StreamReader}

Page 15: Developing for Windows Phone 8 and Windows 8

Convergence through Extension

Page 16: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential16

Extension Methods

Windows Phone 8 HttpWebRequest Extensionpublic static Task<HttpWebResponse> GetResponseAsync(this HttpWebRequest request){ var taskComplete = new TaskCompletionSource<HttpWebResponse>(); request.BeginGetResponse(asyncResponse => { HttpWebRequest responseRequest = (HttpWebRequest)asyncResponse.AsyncState; HttpWebResponse someResponse = (HttpWebResponse)responseRequest.EndGetResponse(asyncResponse); taskComplete.TrySetResult(someResponse); }, request);

return taskComplete.Task;}

Page 17: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential17

HttpWebResponse and HttpWebRequest

Windows 8 AND Windows Phone 8var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);

HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();

// retrieve data using StreamReader

Page 18: Developing for Windows Phone 8 and Windows 8

Convergence through Architecture

Page 19: Developing for Windows Phone 8 and Windows 8

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 20: Developing for Windows Phone 8 and Windows 8

•One source

•One project

•One binary

•Multiple platforms!

Portable Class Libraries

Page 21: Developing for Windows Phone 8 and Windows 8

Portable platform/feature matrix

What can I use and where?

Page 22: Developing for Windows Phone 8 and Windows 8

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 23: Developing for Windows Phone 8 and Windows 8

MVVM w/PCLDemo

Page 24: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential24

UI Differences and XAML

Page 25: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential25

Different Form Factors Require Different UX

Windows Phone 8 Windows 8

Screen Size

800x480

1280x720

1280x768

Screen Size

1024x768

 2,560x1,440

everything in between

Page 26: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential26

Different Form Factors Require Different UX

Windows Phone 8 Windows 8

Orientation

Portrait

Landscape

Orientation

Portrait

Landscape

Snapped

Page 27: Developing for Windows Phone 8 and Windows 8

Microsoft confidential27

Different Controls

GridView

Group-able

Array of Tiles

Dynamic item size

Page 28: Developing for Windows Phone 8 and Windows 8

Microsoft confidential28

Different Controls

FlipView

Browsing View

Touch-optimized for left-right navigation

Page 29: Developing for Windows Phone 8 and Windows 8

Microsoft confidential29

Different Controls

Semantic Zoom

Pinch-zoom through grouped list of items

Page 30: Developing for Windows Phone 8 and Windows 8

Microsoft confidential30

Different Form Factors Require Different UX

Panorama

Introduction and exploratory content

Page 31: Developing for Windows Phone 8 and Windows 8

Microsoft confidential31

Different Form Factors Require Different UX

Pivot

Scanning views

Grouped information

Page 32: Developing for Windows Phone 8 and Windows 8

Microsoft confidential32

Different Form Factors Require Different UX

LongListSelector

Headers and Footers

Group header navigation

Page 33: Developing for Windows Phone 8 and Windows 8

Microsoft confidential33

Translating UX

Semantic Zoom Pivot

Page 34: Developing for Windows Phone 8 and Windows 8

Microsoft confidential34

Translating UX – Details View

Horizontal scroll Vertical scroll

Page 35: Developing for Windows Phone 8 and Windows 8

Microsoft confidential35

Different Form Factors Require Different UXGridView LongListSelector

Page 36: Developing for Windows Phone 8 and Windows 8

Summary

Page 37: Developing for Windows Phone 8 and Windows 8

04/08/2023Microsoft confidential37

• Abstracting Models, ViewModels• Binding data to the View• Linked files• Models, Services could be encapsulated in Portable Class Libraries

• Shared APIs (hardware, storage, base class libraries)

• Using #if conditionals for small code differences

• Using Extension methods to bridge implementation differences• Async-await model for HttpWebResponse/Request

• Focus on the user experience that works for the form factor

Windows 8 / Windows Phone 8 Apps Are a Perfect Match

Page 38: Developing for Windows Phone 8 and Windows 8

The information herein is for informational purposes only an 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.

© 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.

MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.