developing for windows phone 8 and windows 8
DESCRIPTION
TRANSCRIPT
Dave Bost
Technical Evangelist, Windows
Phone
http://davebost.com
@davebost
October 1st 2012
Cross DevelopmentWindows 8 and Windows Phone 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
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
04/08/2023Microsoft confidential4
Common Structure
Windows 8 Windows Phone 8
Common APIs in Windows 8 and Windows Phone 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
04/08/2023Microsoft confidential7
“Add as Link”
04/08/2023Microsoft confidential8
“Add as Link”
Windows 8 Windows Phone 8
04/08/2023Microsoft confidential9
Common APIs
Common
Base Class Library
Hardware
Storage (Files and Folders)
Different
Launchers and Choosers
Sharing APIs
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
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;
04/08/2023Microsoft confidential12
Web Service
04/08/2023Microsoft confidential13
HttpWebResponse and HttpWebRequest
Windows 8var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
// retrieve data using StreamReader
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}
Convergence through Extension
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;}
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
Convergence through Architecture
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
•One source
•One project
•One binary
•Multiple platforms!
Portable Class Libraries
Portable platform/feature matrix
What can I use and where?
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
MVVM w/PCLDemo
04/08/2023Microsoft confidential24
UI Differences and XAML
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
04/08/2023Microsoft confidential26
Different Form Factors Require Different UX
Windows Phone 8 Windows 8
Orientation
Portrait
Landscape
Orientation
Portrait
Landscape
Snapped
Microsoft confidential27
Different Controls
GridView
Group-able
Array of Tiles
Dynamic item size
Microsoft confidential28
Different Controls
FlipView
Browsing View
Touch-optimized for left-right navigation
Microsoft confidential29
Different Controls
Semantic Zoom
Pinch-zoom through grouped list of items
Microsoft confidential30
Different Form Factors Require Different UX
Panorama
Introduction and exploratory content
Microsoft confidential31
Different Form Factors Require Different UX
Pivot
Scanning views
Grouped information
Microsoft confidential32
Different Form Factors Require Different UX
LongListSelector
Headers and Footers
Group header navigation
Microsoft confidential33
Translating UX
Semantic Zoom Pivot
Microsoft confidential34
Translating UX – Details View
Horizontal scroll Vertical scroll
Microsoft confidential35
Different Form Factors Require Different UXGridView LongListSelector
Summary
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
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.